I have a 2D numpy array of shape (N,2) which is holding N points (x and y coordinates). For example:
array([[3, 2], [6, 2], [3, 6], [3,
The numpy_indexed package (disclaimer: I am its author) can be used to solve these kind of processing-on-nd-array problems in an efficient fully vectorized manner:
import numpy_indexed as npi npi.sort(a) # by default along axis=0, but configurable