Documentation
¶
Overview ¶
Package naturally implements "natural" sort ordering: the alphabetic portions of a string are compared alphabetically and the numeric portions are compared numerically, so that "A2" sorts before "A11".
Ordering details worth knowing:
- Numeric segments are compared by value, with no limit on the number of digits, so "99999999999999999999" sorts before "100000000000000000000".
- When two numeric segments have the same value but different lengths, the shorter (less zero-padded) one sorts first: "A1" < "A01" < "A001".
- A string containing a digit sorts before one that does not, so "b2" < "Banana". See the package README for the rationale.
- Segments of non-ASCII digits (for example Arabic-Indic "٣") are compared as text rather than by value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CIStringSlice ¶ added in v0.2.0
type CIStringSlice sort.StringSlice
CIStringSlice attaches the methods of sort.Interface to []string, sorting in natural order while ignoring case.
func (CIStringSlice) Len ¶ added in v0.2.0
func (p CIStringSlice) Len() int
Len is the number of elements in the collection.
func (CIStringSlice) Less ¶ added in v0.2.0
func (p CIStringSlice) Less(a, b int) bool
Less reports whether element a should sort before element b, ignoring case.
func (CIStringSlice) Swap ¶ added in v0.2.0
func (p CIStringSlice) Swap(a, b int)
Swap swaps the elements with indexes a and b.
type StringSlice ¶
type StringSlice sort.StringSlice
StringSlice attaches the methods of sort.Interface to []string, sorting in natural order (case-sensitive).
func (StringSlice) Len ¶
func (p StringSlice) Len() int
Len is the number of elements in the collection.
func (StringSlice) Less ¶
func (p StringSlice) Less(a, b int) bool
Less reports whether element a should sort before element b.
func (StringSlice) Swap ¶
func (p StringSlice) Swap(a, b int)
Swap swaps the elements with indexes a and b.