Reputation: 403
I'm having the following simple array :
a = np.array([
[1, 1000, 58],
[1, 200, 69],
[3, 300, 34],
[4, 400, 82]], dtype = int)
When I issue the following lexsort()
command : i = np.lexsort((a[:,0], a[:,1]))
I'm getting :
array([[ 1, 200, 69],
[ 3, 300, 34],
[ 4, 400, 82],
[ 1, 1000, 58]])
While I was expecting :
array([[ 1, 200, 69],
[ 1, 1000, 58],
[ 3, 300, 34],
[ 4, 400, 82],
])
Can anyone explain me why ? and how do I get the expected output ?
Upvotes: 0
Views: 83
Reputation: 403
Following @Divakar comment. All I had to do is :
i = np.lexsort((a[:,1], a[:,0]))
Thank you
Upvotes: 3