Numpy lexicographic ordering

后端 未结 2 498
無奈伤痛
無奈伤痛 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 20:00

    np.lexsort gives you the index of the columns in lexicographic order, however the order it considers is such that the last element in the column has priority over the previous one and so on. That's why in your example column 5 comes before column 1.

    [2,0,2] < [1,1,2] because 2 = 2 and 0 < 1.

提交回复
热议问题