nat_lex_cmp

Function nat_lex_cmp 

Source
pub fn nat_lex_cmp(a: &str, b: &str) -> Ordering
Expand description

A hybrid comparator for string slices:

  • If the two strings have the same length, performs a standard lexicographical (byte-wise) comparison.
  • Otherwise, falls back to a natural order comparison (natord::compare).

This is useful for sorting lists containing both fixed-length identifiers (like ULIDs) and variable-length names with embedded numbers (like filenames).

§Arguments

  • a: The first string slice.
  • b: The second string slice.

§Returns

An Ordering indicating whether a is less than, equal to, or greater than b.