Skip to content

Commit b2dfbd2

Browse files
committed
Update table sort example with table used in test
1 parent 9e4a76d commit b2dfbd2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

book/sorting.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ Table rows are sorted by comparing rows by the columns in order. If two rows hav
8686

8787
```nu
8888
> let items = [
89-
{id: 100, price: 10, quantity: 5 }
90-
{id: 100, price: 5, quantity: 8 }
91-
{id: 100, price: 5, quantity: 1 }
89+
{id: 100, quantity: 10, price: 5 }
90+
{id: 100, quantity: 5, price: 8 }
91+
{id: 100, quantity: 5, price: 1 }
9292
]
9393
> $items | sort
94-
╭───┬─────┬─────────────────╮
95-
│ # │ id │ pricequantity
96-
├───┼─────┼─────────────────┤
97-
│ 0 │ 100 │ 5 │ 1 │
98-
│ 1 │ 100 │ 5 │ 8 │
99-
│ 2 │ 100 │ 10 │ 5 │
100-
╰───┴─────┴─────────────────╯
94+
╭───┬─────┬─────────────────╮
95+
│ # │ id │ quantityprice
96+
├───┼─────┼─────────────────┤
97+
│ 0 │ 100 │ 5 │ 1 │
98+
│ 1 │ 100 │ 5 │ 8 │
99+
│ 2 │ 100 │ 10 │ 5 │
100+
╰───┴─────┴─────────────────╯
101101
```
102102

103103
In this example, the `id` column for all items is equal. Then, the two items with price `5` are sorted before the item with price `10`. Finally, the `item` with quantity `1` is sorted before the item with quantity `8`.

0 commit comments

Comments
 (0)