polars.Series.arg_sort#

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

Get the index values that would sort this Series.

Parameters:
reverse

Sort in reverse (descending) order.

nulls_last

Place null values last instead of first.

Examples

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