sort
for filters> sort {flags}
--reverse, -r
: Sort in reverse order--ignore-case, -i
: Sort string-based data case-insensitively--values, -v
: If input is a single record, sort the record by values; ignored if input is not a single record--natural, -n
: Sort alphanumeric string-based values naturally (1, 9, 10, 99, 100, ...)input | output |
---|---|
list<any> | list<any> |
record | record |
sort the list by increasing value
> [201] |sort
╭───┬───╮
│0│0│
│1│1│
│2│2│
╰───┴───╯
sort the list by decreasing value
> [201] |sort-r
╭───┬───╮
│0│2│
│1│1│
│2│0│
╰───┴───╯
sort a list of strings
> [bettyamysarah] |sort
╭───┬───────╮
│0│amy│
│1│betty│
│2│sarah│
╰───┴───────╯
sort a list of strings in reverse
> [bettyamysarah] |sort-r
╭───┬───────╮
│0│sarah│
│1│betty│
│2│amy│
╰───┴───────╯
Sort strings (case-insensitive)
> [airplaneTruckCar] |sort-i
╭───┬──────────╮
│0│airplane│
│1│Car│
│2│Truck│
╰───┴──────────╯
Sort strings (reversed case-insensitive)
> [airplaneTruckCar] |sort-i-r
╭───┬──────────╮
│0│Truck│
│1│Car│
│2│airplane│
╰───┴──────────╯
Sort record by key (case-insensitive)
> {b:3, a:4} |sort
╭───┬───╮
│a│4│
│b│3│
╰───┴───╯
Sort record by value
> {b:4, a:3, c:1} |sort-v
╭───┬───╮
│c│1│
│a│3│
│b│4│
╰───┴───╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/sort.html