polars.Series.set_sorted#

Series.set_sorted(*, descending: bool = False) Self[source]#

Flags the Series as ‘sorted’.

Enables downstream code to user fast paths for sorted arrays.

Parameters:
descending

If the Series order is descending.

Warning

This can lead to incorrect results if this Series is not sorted!! Use with care!

Examples

>>> s = pl.Series("a", [1, 2, 3])
>>> s.set_sorted().max()
3