Documentation ¶
Overview ¶
Package sortutil provides methods for sorting slices
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NaturalLess ¶
NaturalLess compares two strings using natural ordering. This means that e.g. "abc2" < "abc12" This code based on sortorder package created by @fvbommel
func Strings ¶
Strings sorts strings slice and support case insensitive mode
Example ¶
stringSlice := []string{ "Alisa", "Luna", "remedios", "Ona", "Eugene", "lorriane", "Zachariah", "cecily", "eleonora", "Dotty", } // Case insensitive sorting Strings(stringSlice, false) fmt.Println(stringSlice) // Case sensitive sorting Strings(stringSlice, true) fmt.Println(stringSlice)
Output: [Alisa Dotty Eugene Luna Ona Zachariah cecily eleonora lorriane remedios] [Alisa cecily Dotty eleonora Eugene lorriane Luna Ona remedios Zachariah]
func StringsNatural ¶
func StringsNatural(a []string)
StringsNatural sorts a slice of strings in natural order Limitation: only ASCII digits (0-9) are considered.
func VersionCompare ¶
VersionCompare compares 2 versions and returns true if v1 less v2. This function can be used for version sorting with structs
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.