numpy: sorting a multidimensional array by a multidimensional array,a[list(np.ogrid[[slice(x) for x in a.shape]][:-1]) + [i]]