polars.Expr.arg_sort#

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

Get the index values that would sort this column.

Parameters:
reverse

Sort in reverse (descending) order.

nulls_last

Place null values last instead of first.

Returns:
Expr

Series of dtype UInt32.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [20, 10, 30],
...     }
... )
>>> df.select(pl.col("a").arg_sort())
shape: (3, 1)
┌─────┐
│ a   │
│ --- │
│ u32 │
╞═════╡
│ 1   │
├╌╌╌╌╌┤
│ 0   │
├╌╌╌╌╌┤
│ 2   │
└─────┘