polars.Series.arg_sort#

Series.arg_sort(
*,
descending: bool = False,
nulls_last: bool = False,
) Series[source]#

Get the index values that would sort this Series.

Parameters:
descending

Sort in descending order.

nulls_last

Place null values last instead of first.

See also

Series.gather

Take values by index.

Series.rank

Get the rank of each row.

Examples

>>> s = pl.Series("a", [5, 3, 4, 1, 2])
>>> s.arg_sort()
shape: (5,)
Series: 'a' [u32]
[
    3
    4
    1
    2
    0
]