pub fn sort(
vec: &mut [Value],
insensitive: bool,
natural: bool,
) -> Result<(), ShellError>
Expand description
Sort a slice of Value
s.
Sort has the following invariants, in order of precedence:
- Null values (Nothing type) are always sorted to the end.
- For natural sort, numeric values (numeric strings, ints, and floats) appear first, sorted by numeric value
- Values appear by order of
Value
’sPartialOrd
. - Sorting for values with equal ordering is stable.
Generally, values of different types are ordered by order of appearance in the Value
enum.
However, this is not always the case. For example, ints and floats will be grouped together since
Value
’s PartialOrd
defines a non-decreasing ordering between non-decreasing integers and floats.