import numpy as np x = np.array([3, 1, 2]) np.argsort(x) Out[4]: array([1, 2, 0]) # 疑问点 In [13]: x = np.array([6,5,4,3,2,1]) In [14]: In [14]: np.argsort(x) Out[14]: array([5, 4, 3, 2, 1, 0])
Why not[2,0,1]
[2,0,1]
光阴似箭催人老,日月如移越少年。
argsort returns the sorting of index values For np.argsort([3,1,2]), the corresponding index value is [0, 1, 2], so the sorted index value returns [1, 2, 0]
argsort returns the sorting of index values
For np.argsort([3,1,2]), the corresponding index value is [0, 1, 2], so the sorted index value returns [1, 2, 0]