如何通过内部列表的特定索引对列表列表进行排序? [英] How to sort a list of lists by a specific index of the inner list?

查看:50
本文介绍了如何通过内部列表的特定索引对列表列表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个清单清单.例如,

I have a list of lists. For example,

[
[0,1,'f'],
[4,2,'t'],
[9,4,'afsd']
]

如果我想按内部列表的字符串字段对外部列表进行排序,您将如何在python中做到这一点?

If I wanted to sort the outer list by the string field of the inner lists, how would you do that in python?

推荐答案

这是在这里也可以使用lambda函数,但是在这种简单情况下,lambda函数的速度较慢

It is also possible to use a lambda function here, however the lambda function is slower in this simple case

这篇关于如何通过内部列表的特定索引对列表列表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆