Sorting arrays in NumPy by column

How do I sort a NumPy array by its nth column?

For example, given:

a = array([[9, 2, 3],
           [4, 5, 6],
           [7, 0, 5]])

I want to sort the rows of a by the second column to obtain:

array([[7, 0, 5],
       [9, 2, 3],
       [4, 5, 6]])

← Назад к списку