OrderingBy
OrderingBy[list, f] gives the positions in list at which each successive element of SortBy[list, f] appears.
OrderingBy[list, f, n]gives the positions in list at which the first n elements ofSortBy[list, f]appear.OrderingBy[list, f, -n]gives the positions of the last n elements ofSortBy[list, f].OrderingBy[list, f, n, p]gives positions in list of elements ofSortBy[list, f, p].OrderingBy[f]represents an operator form ofOrderingBythat can be applied to an expression.
Examples
OrderingBy[{"apple", "pear", "banana"}, StringLength]OrderingBy[{-3, 1, 5, -2}, Abs, 2]Please visit the official Wolfram Language Reference for more details.