I want to sort the following input by 1st column:
a = np.array([(2, 1), (1, 2), (2, 3)], dtype=[('c1', int), ('c2', int)])
[[2, 1],
[1, 2],
[2, 3]]
I've tried a.sort(order='c1')
followed by print(a[::-1]
.
Expected output (2nd column order is preserved):
[[2, 1],
[2, 3],
[1, 2]]
Actual output:
[[2, 3],
[2, 1],
[1, 2]]