Skip to content

Sort a Series

Source code

Description

Sort a Series

Usage

<Series>$sort(
  ...,
  descending = FALSE,
  nulls_last = FALSE,
  multithreaded = TRUE,
  in_place = FALSE
)

Arguments

Ignored.
descending A logical. If TRUE, sort in descending order.
nulls_last A logical. If TRUE, place null values last insead of first.
multithreaded A logical. If TRUE, sort using multiple threads.
in_place If TRUE, this will set the flag mutably and return NULL. Remember to use options(polars.strictly_immutable = FALSE) before using this parameter, otherwise an error will occur. If FALSE (default), it will return a cloned Series with the flag.

Value

Series

Examples

library(polars)

as_polars_series(c(1.5, NA, 1, NaN, Inf, -Inf))$sort()
#> polars Series: shape: (6,)
#> Series: '' [f64]
#> [
#>  null
#>  -inf
#>  1.0
#>  1.5
#>  inf
#>  NaN
#> ]
as_polars_series(c(1.5, NA, 1, NaN, Inf, -Inf))$sort(nulls_last = TRUE)
#> polars Series: shape: (6,)
#> Series: '' [f64]
#> [
#>  -inf
#>  1.0
#>  1.5
#>  inf
#>  NaN
#>  null
#> ]