Documentation ¶
Overview ¶
natsort implements Martin Pool's Natural Order String Comparison Original implementation: https://github.com/sourcefrog/natsort
Strings are sorted as usual, except that decimal integer substrings are compared on their numeric value. For example:
a < a0 < a1 < a1a < a1b < a2 < a10 < a20
All white space and control characters are ignored.
Leading zeros are *not* ignored, which tends to give more reasonable results on decimal fractions:
1.001 < 1.002 < 1.010 < 1.02 < 1.1 < 1.3
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare tests if a is less than, equal to, or greater than b according to the natural sorting algorithm, returning -1, 0, or +1 respectively.
func Less ¶
Less determines if a naturally comes before b. Unlike Compare it will fall back to a normal string comparison which considers spaces if the two would otherwise be equal. That helps ensure the stability of sorts.
func StringsAreSorted ¶
StringsAreSorted tests whether a slice of strings is natural sorted.
Types ¶
This section is empty.