polars.Series.set_sorted#

Series.set_sorted(reverse: bool = False) Series[source]#

Flags the Series as ‘sorted’.

Enables downstream code to user fast paths for sorted arrays.

Parameters:
reverse

If the Series order is reversed, e.g. 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