sort-by
for filters
Sort by the given columns, in increasing order.
Signature
> sort-by ...rest --reverse --ignore-case --natural
Parameters
...rest
: the column(s) to sort by--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, ...)
Input/output types:
input | output |
---|---|
list<any> | list<any> |
table | table |
Examples
Sort files by modified date
> ls | sort-by modified
Sort files by name (case-insensitive)
> ls | sort-by name -i
Sort a table by a column (reversed order)
> [[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit -r
╭───┬────────┬───────╮
│ # │ fruit │ count │
├───┼────────┼───────┤
│ 0 │ pear │ 3 │
│ 1 │ orange │ 7 │
│ 2 │ apple │ 9 │
╰───┴────────┴───────╯