I need to sort by the first column in descending order an array. To be specific my code is:
>>> x = np.array([[2, 3], [1998,5], [1998,7]])
>>> x = x[np.argsort(x[:,0])]
but the output is
array([[   2,    3],
       [1998,    5],
       [1998,    7]])
but I need it in descending order. Can someone explain me how to do that?
EDIT: @Babyburger suggested this solution :
x = x[np.argsort(x[:,0])][::-1]
that give
array([[1998,    7],
       [1998,    5],
       [   2,    3]])
it could be fine, but i would like that where the value on the first column is the same, the order is not changed. So the output would be
array([[1998,    5],
       [1998,    7],
       [   2,    3]])
is there a simple way to do that?