fork download
  1. L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
  2.  
  3. def by_score(t):
  4. return t[:][1]
  5.  
  6. L2 = sorted(L, key=by_score)
  7. print(L2)
  8.  
Success #stdin #stdout 0.09s 14164KB
stdin
Standard input is empty
stdout
[('Bart', 66), ('Bob', 75), ('Lisa', 88), ('Adam', 92)]