Is there a way to sort the rows of a numpy ndarray using a key (or comparator) function, without resorting to converting to a python list?
In particular, I need to
your approach is right, it is similar to the Schwartzian transform or Decorate-Sort-Undecorate (DSU) idiom
As I said you can use the numpy function np.argsort. It does the work of your order_to_index.
order_to_index