Human numeric sort (-h): handles suffixes K, M, G, T, P, E, Z, Y.
GNU sort compares by suffix tier first (no-suffix < K < M < G < T < P < E < Z < Y),
then by numeric value within the same tier. This means 1K > 999999 and 1G > 1023M.
Case-insensitive lexicographic comparison.
Tight loop specialized for fold-case only (no dict/nonprinting filtering),
avoiding the overhead of the general compare_text_filtered path.
Compare two byte slices using locale-aware collation (strcoll).
Uses stack buffers (up to 256 bytes) to avoid heap allocation in the hot path.
Falls back to heap-allocated CString for longer strings, and to byte comparison
if the input contains interior null bytes.
Convert a human-numeric string directly to a sortable u64.
Encodes tier in the top 4 bits and the float value in the bottom 60 bits.
This avoids the f64 precision loss that would occur from encoding tier + value
in a single f64 (e.g., 1e18 + 3.0 == 1e18 + 1.0 due to 52-bit mantissa).
Convert an i64 to a sortable u64 whose natural ordering matches signed integer ordering.
Adds i64::MAX + 1 (0x8000000000000000) to shift the range to unsigned.
Fast custom numeric parser: parses sign + digits + optional decimal directly from bytes.
Avoids UTF-8 validation and str::parse::() overhead entirely.
Uses batch digit processing for the integer part (4 digits at a time) to reduce
loop iterations and branch mispredictions.
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.
Fast integer-only parser for numeric sort (-n).
Returns Some(i64) if the value is a pure integer (no decimal point, no exponent).
Returns None if the value has a decimal point or is not a valid integer.
This avoids the f64 conversion path for integer-only data.
Uses wrapping arithmetic (no overflow checks) for speed — values >18 digits
may wrap but sort order is still consistent since all values wrap the same way.