如何按列表中的整数对列表列表进行排序

时间:2016-05-05 07:49:10

标签: python python-2.7

biglist = [['Bob', 10], ['Karl', 12], ['Judy', 11]]

customsort(biglist) 

应该返回:

biglist = [['Bob', 10],  ['Judy', 11], ['Karl', 12]]

1 个答案:

答案 0 :(得分:1)

>>> biglist = [['Bob', 10], ['Karl', 12], ['Judy', 11]]
>>> sorted(biglist, key=lambda x:x[1])
[['Bob', 10], ['Judy', 11], ['Karl', 12]]