Numpy: sort by key function

后端 未结 1 1818
一整个雨季
一整个雨季 2021-01-02 08:33

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

相关标签:
1条回答
  • 2021-01-02 09:16

    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.

    0 讨论(0)
提交回复
热议问题