Documentation ¶
Overview ¶
Package natsort implements natural sort. In "Natural Sort Order" integers embedded in strings are compared by value.
References:
https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Less ¶
Less compares two strings using natural ordering. This means that e.g. "abc2" < "abc12".
Non-digit sequences and numbers are compared separately. The former are compared bytewise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")
Limitation: only ASCII digits (0-9) are considered.
Types ¶
type Order ¶
type Order []string
Order implements sort.Interface to sort strings in natural order. This means that e.g. "abc2" < "abc12".
Non-digit sequences and numbers are compared separately. The former are compared bytewise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")
Limitation: only ASCII digits (0-9) are considered.