Numpy lexicographic ordering

后端 未结 2 465
無奈伤痛
無奈伤痛 2021-01-21 19:02

I\'d like to lexicographically sort the following array a (get index positions), but, I\'m having problems understanding the numpy results:

>>>         


        
2条回答
  •  终归单人心
    2021-01-21 19:36

    The order of significance for keys is opposite to what you expected. In order to get expected result just flip the matrix upside down

    >>> np.lexsort(np.flipud(a))
    array([1, 4, 0, 2, 5, 3])
    

提交回复
热议问题