Sorting lists in python

后端 未结 3 1147
无人共我
无人共我 2020-12-21 18:59

Okay, so I have a bit of a problem, Im new to python sorry.

I am trying to sort a list by score, which is a number, but if there is a draw I need to sort them by the

3条回答
  •  萌比男神i
    2020-12-21 19:24

    aList = [
        (11, 'Jenny'),
        (8, 'Adam'),
        (10, 'Mark'),
        (8, 'Ada'),
    ]
    
    aList.sort(lambda x, y: y[0] - x[0])
    print aList
    

提交回复
热议问题