unsorting_indices

halotools.utils.unsorting_indices(sorting_indices)[source] [edit on github]

Return the indexing array that inverts numpy.argsort.

Parameters:

sorting_indices : array_like

Length-Npts array - the output of numpy.argsort

Returns:

unsorting_indices : array_like

Length-Npts array

Examples

>>> x = np.random.rand(100)
>>> idx_sorted = np.argsort(x)
>>> x_sorted = x[idx_sorted]
>>> idx_unsorted = unsorting_indices(idx_sorted)
>>> assert np.all(x == x_sorted[idx_unsorted])