Skip to main content

resolve_sort_options

Function resolve_sort_options 

Source
pub fn resolve_sort_options(
    s: &Series,
    descending: Option<bool>,
    nulls_last: Option<bool>,
) -> PolarsResult<(Option<bool>, Option<bool>)>
Expand description

Infers the (descending, nulls_last) sort options for s, honoring any provided hints.

Each returned value is Some when known — taken from the corresponding hint when given, otherwise inferred from the data — and None when it cannot be inferred from s alone:

  • descending is None when there are fewer than two distinct non-null values, so no direction is implied.
  • nulls_last is None when s has no nulls, is entirely null, or the nulls are interleaved (the last of which is not sorted under any placement and is rejected by the is_sorted check).

The two axes are independent, so callers can use whichever was determined even when the other could not be.