Method: Polars::Expr#arg_sort

Defined in:
lib/polars/expr.rb

#arg_sort(reverse: false, nulls_last: false) ⇒ Expr

Get the index values that would sort this column.

Examples:

df = Polars::DataFrame.new(
  {
    "a" => [20, 10, 30]
  }
)
df.select(Polars.col("a").arg_sort)
# =>
# shape: (3, 1)
# ┌─────┐
# │ a   │
# │ --- │
# │ u32 │
# ╞═════╡
# │ 1   │
# │ 0   │
# │ 2   │
# └─────┘

Parameters:

  • reverse (Boolean) (defaults to: false)

    Sort in reverse (descending) order.

  • nulls_last (Boolean) (defaults to: false)

    Place null values last instead of first.

Returns:

[View source]

1459
1460
1461
# File 'lib/polars/expr.rb', line 1459

def arg_sort(reverse: false, nulls_last: false)
  _from_rbexpr(_rbexpr.arg_sort(reverse, nulls_last))
end