Sort python list by first element
>>> lis = [[1,4,7],[3,6,9],[2,59,8]]
>>> lis.sort()
>>> lis
[[1, 4, 7], [2, 59, 8], [3, 6, 9]]
4.4
5
li = [[1,4,7],[3,6,9],[2,59,8]]
li.sort(key=lambda x: int(x[0]))
Thank you!
5
0
Are there any code examples left?
New code examples in category Other