I have 2 1D numpy arrays of the same dimension, a
and b
, and I want to sort
the arrays using the values in b
. This can be achieved with lists as outlined
in this previous post or by using numpy’s argsort.
First we make some example data
So our data looks like:
We can then use argsort
on b
to get the indexes of b
if it was sorted:
And then apply these indexes to our original data to reorder it:
Which yields: