Skip to content

Sort values in a list

Source code

Description

Sort values in a list

Usage

<Expr>$list$sort(descending = FALSE)

Arguments

descending Sort values in descending order

Value

Expr

Examples

library(polars)

df = pl$DataFrame(values = list(c(NA, 2, 1, 3), c(Inf, 2, 3, NaN), NA_real_))
df$with_columns(sort = pl$col("values")$list$sort())
#> shape: (3, 2)
#> ┌────────────────────┬────────────────────┐
#> │ values             ┆ sort               │
#> │ ---                ┆ ---                │
#> │ list[f64]          ┆ list[f64]          │
#> ╞════════════════════╪════════════════════╡
#> │ [null, 2.0, … 3.0] ┆ [null, 1.0, … 3.0] │
#> │ [inf, 2.0, … NaN]  ┆ [2.0, 3.0, … NaN]  │
#> │ [null]             ┆ [null]             │
#> └────────────────────┴────────────────────┘