nushell/docs/commands/sort-by.md

50 lines
820 B
Markdown
Raw Normal View History

---
title: sort-by
layout: command
version: 0.59.1
---
2019-10-21 17:59:20 +02:00
Sort by the given columns, in increasing order.
2019-10-21 17:59:20 +02:00
## Signature
2019-10-21 17:59:20 +02:00
```> sort-by ...columns --reverse --insensitive```
2019-10-21 17:59:20 +02:00
## Parameters
- `...columns`: the column(s) to sort by
- `--reverse`: Sort in reverse order
- `--insensitive`: Sort string-based columns case-insensitively
## Examples
2019-10-21 17:59:20 +02:00
sort the list by increasing value
```shell
> [2 0 1] | sort-by
2019-10-21 17:59:20 +02:00
```
sort the list by decreasing value
```shell
> [2 0 1] | sort-by -r
2019-10-21 17:59:20 +02:00
```
sort a list of strings
```shell
> [betty amy sarah] | sort-by
```
sort a list of strings in reverse
```shell
> [betty amy sarah] | sort-by -r
```
Sort strings (case-insensitive)
```shell
> echo [airplane Truck Car] | sort-by -i
```
Sort strings (reversed case-insensitive)
```shell
> echo [airplane Truck Car] | sort-by -i -r
```