Answers for "sort list of lists by first element"

3

sort list of lists by first element

>>> lis = [[1,4,7],[3,6,9],[2,59,8]]
>>> sorted(lis, key=lambda x: x[0])
[[1, 4, 7], [2, 59, 8], [3, 6, 9]]
Posted by: Guest on October-25-2020
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 list of lists by first element"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language