numpy sort multidimensional array 1

numpy sort multidimensional array

a[a[:, 1].argsort()]

Here is what the above code is Doing:
1. We’re sorting the array by the second column.
2. We’re then taking the sorted array and sorting it by the first column.
3. We’re then taking the sorted array and sorting it by the second column.

The result is that the array is sorted by the second column, then the first column.

Similar Posts