I was working on a geometry project in python and I came across an intriguing problem. Assume I have a list of Cartesian coordinates like this:
[[1, 0], [3, 0], [2, 1], [3.5, 2], [4, 3], [6, 1], [6.5, 0], [10, 2], [10, 5], [9, 3.5], [7, 3], [9, 7], [7, 8], [5, 7], [4, 5], [2, 8], [1, 7], [0, 5], [1, 3], [0, 2]]
What would be the best way to sort this list by descending y-value THEN increasing x-value if two coordinates exist with the same y-value? The output should be:
[[2, 8], [7, 8], [1, 7], [5, 7], [9, 7], [0, 5], [4, 5], [10, 5], [9, 3.5], [1, 3], [4, 3], [7, 3], [0, 2], [3.5, 2], [10, 2], [2, 1], [6, 1], [1, 0], [3, 0], [6.5, 0]]