Answers for "Sort python list by first element"

0

Sort python list by first element

li = [[1,4,7],[3,6,9],[2,59,8]]
li.sort(key=lambda x: int(x[0]))
Posted by: Guest on June-29-2021
0

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]]
Posted by: Guest on June-29-2021

Code answers related to "Sort python list by first element"

Browse Popular Code Answers by Language