Answers for "sort the list of x, y pair with x"

0

sort the list of x, y pair with x

>>> my_list = [[1,2],[0,2],[2,1],[1,1],[2,2],[2,0],[0,1],[1,0],[0,0]]
>>> sorted(my_list , key=lambda k: [k[1], k[0]])
[[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2]]
Posted by: Guest on January-07-2021

Browse Popular Code Answers by Language