Skip to main content

Module compare

Module compare 

Source

Functions§

compare_dictionary
compare_general_numeric
General numeric sort (-g): handles scientific notation, infinity, NaN. O(n) parser.
compare_human_numeric
Human numeric sort (-h): handles suffixes K, M, G, T, P, E, Z, Y.
compare_ignore_case
compare_ignore_nonprinting
compare_lexical
Compare two byte slices lexicographically (default sort).
compare_month
Month sort (-M).
compare_numeric
Numeric sort (-n): compare leading numeric strings. Handles optional leading whitespace, sign, and decimal point.
compare_random
Random sort (-R): hash-based shuffle that groups identical keys.
compare_version
Version sort (-V): natural sort of version numbers. Uses byte slices directly instead of char iterators for maximum performance.
compare_with_opts
Master comparison function that dispatches based on KeyOpts.
parse_general_numeric
parse_human_numeric
parse_numeric_value
Fast custom numeric parser: parses sign + digits + optional decimal directly from bytes. Avoids UTF-8 validation and str::parse::() overhead entirely.
select_comparator
Select a concrete comparison function based on KeyOpts. Returns (compare_fn, needs_leading_blank_strip, needs_reverse). The caller applies blank-stripping and reversal outside the function pointer, eliminating all per-comparison branching.
skip_leading_blanks
Strip leading blanks (space and tab).

Type Aliases§

CompareFn
Concrete comparison function type. Selected once at setup time to avoid per-comparison flag checking in hot sort loops.