For example, I have a numpy array like: a = np.array([0.5, 0.1, 0.5)].
When I use np.argsort(a)[::-1] to sort my array in descending order, it returns:
2, 0, 1
Which is technically correct, as np.argsort(a) would return:
1, 0, 2
and I am just reversing the order.
However, I want the sort to be in the order as the original array, so I would like the return to be:
0, 2, 1
How do I do that? Is there a better function than np.argsort()?
I would try like this
np.argsort(-1 * a)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.