python数组的.argsort(),返回从小到大排序后,原位置所对应的索引,而数组并没有排序
import numpy as np
distances = array([2,1,7,6,9])
sortindex = distances.argsort()
print(sortindex)#返回的是索引(数组的下标)
print(distances)#排序并没有变化
[1 0 3 2 4]
[2 1 7 6 9]
python数组的.argsort(),返回从小到大排序后,原位置所对应的索引,而数组并没有排序
import numpy as np
distances = array([2,1,7,6,9])
sortindex = distances.argsort()
print(sortindex)#返回的是索引(数组的下标)
print(distances)#排序并没有变化