mirror of
https://github.com/nushell/nushell.git
synced 2025-02-13 09:00:07 +01:00
* Fix #4942, and add a table sorting example for `sort-by` command * ci skip
This commit is contained in:
parent
7c92791eed
commit
b007290a4e
@ -351,7 +351,7 @@ ls | each {|x| $x.name}
|
|||||||
```
|
```
|
||||||
The above will create a list of the filenames in the directory.
|
The above will create a list of the filenames in the directory.
|
||||||
```
|
```
|
||||||
if true { echo "it's true" } { echo "it's not true" }
|
if true { echo "it's true" } else { echo "it's not true" }
|
||||||
```
|
```
|
||||||
This `if` call will run the first block if the expression is true, or the
|
This `if` call will run the first block if the expression is true, or the
|
||||||
second block if the expression is false.
|
second block if the expression is false.
|
||||||
|
@ -97,6 +97,27 @@ impl Command for SortBy {
|
|||||||
span: Span::test_data(),
|
span: Span::test_data(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
Example {
|
||||||
|
description: "Sort a table by its column (reversed order)",
|
||||||
|
example: "[[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit -r",
|
||||||
|
result: Some(Value::List {
|
||||||
|
vals: vec![
|
||||||
|
Value::test_record(
|
||||||
|
vec!["fruit", "count"],
|
||||||
|
vec![Value::test_string("pear"), Value::test_int(3)],
|
||||||
|
),
|
||||||
|
Value::test_record(
|
||||||
|
vec!["fruit", "count"],
|
||||||
|
vec![Value::test_string("orange"), Value::test_int(7)],
|
||||||
|
),
|
||||||
|
Value::test_record(
|
||||||
|
vec!["fruit", "count"],
|
||||||
|
vec![Value::test_string("apple"), Value::test_int(9)],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
span: Span::test_data(),
|
||||||
|
}),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user