Function argSortBy

  • Return the row indices that would sort the columns.

    Parameters

    • exprs: string[] | pl.Expr[]

      Column(s) to arg sort by. Accepts expression input.

    • descending: boolean | boolean[] = false

      Sort in descending order. When sorting by multiple columns, can be specified per column by passing a sequence of booleans.

    Returns pl.Expr

    const df = pl.DataFrame({"a": [0, 1, 1, 0], "b": [3, 2, 3, 2],});
    df.select(pl.argSortBy(pl.col("a")));
    shape: (4, 1)
    ┌─────┐
    a
    │ --- │
    u32
    ╞═════╡
    0
    3
    1
    2
    └─────┘