Documentation
¶
Overview ¶
Package natural implements "Natural Sort Order" for strings. This allows sorting strings in a way that numbers in strings are compared numerically, rather than lexicographically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare implements natural sort order for strings, where numbers inside strings are compared numerically. For example:
"uint8" < "uint16" < "uint32"
The implementation conceptually splits the string into components of digits and non-digits. Non-digit sequences are compared lexicographically. Digit sequences are compared numerically. When numeric values are equal, the one with fewer leading zeros is considered smaller. For example:
"01" < "001" < "02"
The numeric components consist only of sequences of decimal digits [0-9] denoting non-negative integers. For example:
"1e6" < "10e5" "0xAB" < "0xB" "-5" < "-10"
Types ¶
This section is empty.