argSortOf

fnsize_t[] argSortOf(Series series, bool descending = false, bool nullsLast = false)

Sorts the indices of a Series by its values.

The valid entries sort as (key, index) pairs with the index tie-break always applied, so equal keys keep their original order (stability); the null indices partition out and go before the valid ones (nullsLast = false, the Polars default) or after them. Floats compare with the total order (NaN greatest, -0.0 equal to 0.0).

Parameters

seriesthe key column
descendinglargest keys first
nullsLastnulls after the valid entries instead of before

Returns

the permutation that sorts the column, argSort style.