unsorting_indices

halotools.utils.unsorting_indices(sorting_indices)[source]

Return the indexing array that inverts numpy.argsort.

Parameters:
sorting_indicesarray_like

Length-Npts array - the output of numpy.argsort

Returns:
unsorting_indicesarray_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])