sort-by for filters

Sort by the given columns, in increasing order.

Signature

> sort-by {flags} ...rest

Flags

  • --reverse, -r: Sort in reverse order
  • --ignore-case, -i: Sort string-based columns case-insensitively
  • --natural, -n: Sort alphanumeric string-based columns naturally (1, 9, 10, 99, 100, ...)

Parameters

  • ...rest: the column(s) to sort by

Input/output types:

input output
list<any> list<any>
record table
table table

Examples

Sort files by modified date

> ls | sort-by modified

Sort files by name (case-insensitive)

> ls | sort-by name --ignore-case

Sort a table by a column (reversed order)

> [[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit --reverse
╭───┬────────┬───────╮
│ # │ fruit  │ count │
├───┼────────┼───────┤
│ 0 │ pear   │     3 │
│ 1 │ orange │     7 │
│ 2 │ apple  │     9 │
╰───┴────────┴───────╯