Skip to content

Commit 68517d9

Browse files
committed
Add extra suggestions for sorting mixed types
1 parent 6a00e84 commit 68517d9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

book/sorting.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,12 @@ Under some circumstances, you might need to sort data containing mixed types. Th
362362
- The ordering between non-intermixed types is not guaranteed, **except** for `null` values, which will always be sorted to the end of a list.
363363
- Within the same Nushell version the ordering should always be the same, but this should not be relied upon. If you have code which is sensitive to the ordering across types, consider using a [custom sort](#custom-sort-order) which better expresses your requirements.
364364

365-
If you need to sort data which may contain mixed types, consider using [strict sort](#strict-sort), [natural sort](#natural-sort), or a [custom sort](#custom-sort-order) using [`describe`](https://www.nushell.sh/commands/docs/describe.html).
365+
If you need to sort data which may contain mixed types, consider one of the following strategies:
366+
367+
- [Strict sort](#strict-sort) to disallow sorting of incompatible types
368+
- [Natural sort](#natural-sort) to sort intermixed numbers and numeric strings
369+
- A [key sort](#sort-by-key-closure) using [`to text`](/commands/docs/to_text.html), [`to nuon`](/commands/docs/to_nuon.html), or [`to json`](/commands/docs/to_json.html), as appropriate
370+
- A [custom sort](#custom-sort-order) using [`describe`](/commands/docs/describe.html) to explicitly check types
366371

367372
### Strict sort
368373

0 commit comments

Comments
 (0)