I am using the sort_index() function in c++ armadillo, and it does not seem to give the correct result:
input vector is [3,4,2,1,5] sorting both directions
arma::sort_index(input, "ascend").print();
arma::sort_index(input, "descend").print();
and obtain the following results: [3,2,0,1,4] and [4,1,0,2,3]
which neither is correct. Sorting according to ascending order should give [2,3,1,0,4] (doubled checked with numpy.searchsorted
and it gives the above result).
--- Edit ---
Thanks for the replies! I realize now that I misunderstood the way sort_index
is indexing. I am still trying to find an efficient, equivalent function that achieves np.searchsorted
in c++...