There is an array as below; I used the following codes to sort this array by the second column but without success. Is there anyone to help? Answer np.take(x, x[:, 1].astype(int).argsort(), 0) You may just cast the values for sorting. The overall result of you np.take() will remain as strings.
Tag: np.argsort
How to using numpy.argsort on a 2D array to sort another 2D array
I use numpy.argsort all the time for 1D data, but it seems to behaving differently in 2D. For example, let’s say I want to argsort this array along axis 1 so the items in each row are in ascending order All fine so far. Each row in the above gives the order to how the columns should be rearranged in