search

Home  >  Q&A  >  body text

python - numpy data sorting problem

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]

大家讲道理大家讲道理2750 days ago698

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-18 10:48:48

    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]

    reply
    0
  • Cancelreply