Python-如何按每个列表中的第四个元素对列表列表进行排序? [英] Python - How to sort a list of lists by the fourth element in each list?
本文介绍了Python-如何按每个列表中的第四个元素对列表列表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按每个单独列表中的第四个元素(整数)对以下列表列表进行排序.
I would like to sort the following list of lists by the fourth element (the integer) in each individual list.
unsorted_list = [['a','b','c','5','d'],['e','f','g','3','h'],['i','j','k','4','m']]
我该怎么做? 谢谢!
推荐答案
unsorted_list.sort(key=lambda x: x[3])
这篇关于Python-如何按每个列表中的第四个元素对列表列表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文