I have a numpy array and want to get both the sorted array and the correspoding indices from an original one. E.g.
arr = [2,1,3]
sorted_arr = [1,2,3]
sorted_indices = [1,0,2]
I know I can use np.sort(arr)
and np.argsort(arr)
to find them separately. But is there more efficient way that doesn't require sorting one array two times?