Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

function to sort a list of points based on their x and y-coordinates

>>> 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]]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #function #sort #list #points #based
ADD COMMENT
Topic
Name
1+4 =