I\'d like to lexicographically sort the following array a (get index positions), but, I\'m having problems understanding the numpy results:
>>>
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])
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
.