2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: sort-by
|
|
|
|
layout: command
|
|
|
|
version: 0.59.0
|
|
|
|
---
|
2019-10-21 17:59:20 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Sort by the given columns, in increasing order.
|
2019-10-21 17:59:20 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
2019-10-21 17:59:20 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
```> sort-by ...columns --reverse --insensitive```
|
2019-10-21 17:59:20 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Parameters
|
2020-07-20 19:31:58 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `...columns`: the column(s) to sort by
|
|
|
|
- `--reverse`: Sort in reverse order
|
|
|
|
- `--insensitive`: Sort string-based columns case-insensitively
|
2020-07-20 19:31:58 +02:00
|
|
|
|
2020-06-23 20:21:47 +02:00
|
|
|
## Examples
|
2019-10-21 17:59:20 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
sort the list by increasing value
|
2020-03-13 18:23:41 +01:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [2 0 1] | sort-by
|
2019-10-21 17:59:20 +02:00
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
sort the list by decreasing value
|
2020-03-13 18:23:41 +01:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [2 0 1] | sort-by -r
|
2019-10-21 17:59:20 +02:00
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
sort a list of strings
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [betty amy sarah] | sort-by
|
2020-06-23 20:21:47 +02:00
|
|
|
```
|
2020-07-20 19:31:58 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
sort a list of strings in reverse
|
2020-07-20 19:31:58 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [betty amy sarah] | sort-by -r
|
2020-07-20 19:31:58 +02:00
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Sort strings (case-insensitive)
|
|
|
|
```shell
|
|
|
|
> echo [airplane Truck Car] | sort-by -i
|
|
|
|
```
|
2020-07-20 19:31:58 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Sort strings (reversed case-insensitive)
|
2020-07-20 19:31:58 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo [airplane Truck Car] | sort-by -i -r
|
2020-07-20 19:31:58 +02:00
|
|
|
```
|