Skip to content

Sort an Expr

Source code

Description

Sort this column. If used in a groupby context, the groups are sorted.

Usage

<Expr>$sort(..., descending = FALSE, nulls_last = 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.

Value

Expr

Examples

library("polars")

pl$DataFrame(a = c(6, 1, 0, NA, Inf, NaN))$
  with_columns(sorted = pl$col("a")$sort())
#> shape: (6, 2)
#> ┌──────┬────────┐
#> │ a    ┆ sorted │
#> │ ---  ┆ ---    │
#> │ f64  ┆ f64    │
#> ╞══════╪════════╡
#> │ 6.0  ┆ null   │
#> │ 1.0  ┆ 0.0    │
#> │ 0.0  ┆ 1.0    │
#> │ null ┆ 6.0    │
#> │ inf  ┆ inf    │
#> │ NaN  ┆ NaN    │
#> └──────┴────────┘