我想按照列表中第七个元素的值按降序排列这个列表列表:
<a href="Google.com"> <div class="center">
<h1>
Google
</h1>
</div>
</a>
怎么做?提前谢谢!
答案 0 :(得分:0)
使用itemgetter
:
>> from operator import itemgetter
>> unsorted_list = [["a", 5, 6, 3, 2, 4, 8], ["b", 5, 2, 7, 1, 10, 3],
["c", 2, 6, 3, 7, 11, 13]]
>> sorted(unsorted_list, key=itemgetter(6))
[['b', 5, 2, 7, 1, 10, 3], ['a', 5, 6, 3, 2, 4, 8], ['c', 2, 6, 3, 7, 11, 13]]