From the answer to this question (Sort a numpy array by another array, along a particular axis, using less memory), I learned how to sort a multidimensional numpy array a
by the values of another numpy array b
without creating too many additional arrays.
However, numpy.rec.fromarrays([a, b])
only works if the arrays a
and b
have the same shape. My b
array is 1-D array, but a
array is a N-D array (N is not specified). Is it a nice way (and efficient) to sort the a
array among a particular axis by the value of the 1-D array b
?