Documentation
¶
Overview ¶
Package versionsort provides sorting utilities in natural version order like sort -V.
References: - https://www.gnu.org/software/coreutils/manual/html_node/Details-about-version-sort.html - https://github.com/ekg/filevercmp
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sort ¶
Sort sorts give strings with natural version numbers in text like sort -V.
Example ¶
strs := []string{
"v1.1",
"v1.10",
"v1.11",
"v1.9",
"v1.8",
}
Sort(strs, false)
for _, s := range strs {
fmt.Println(s)
}
Output: v1.1 v1.8 v1.9 v1.10 v1.11
Example (Haya14busa) ¶
strs := []string{
"haya2busa",
"haya1busa",
"haya14busa",
"haya13busa",
}
Sort(strs, false)
for _, s := range strs {
fmt.Println(s)
}
Output: haya1busa haya2busa haya13busa haya14busa
Example (Reverse) ¶
strs := []string{
"v1.1",
"v1.9",
"v1.8",
"v1.10",
"v1.11",
}
Sort(strs, true)
for _, s := range strs {
fmt.Println(s)
}
Output: v1.11 v1.10 v1.9 v1.8 v1.1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.