Documentation
¶
Overview ¶
Package natural defines a natural "less" to compare two strings while interpreting natural numbers.
Example ¶
package main
import (
"fmt"
"sort"
"strings"
"github.com/maruel/natural"
)
func main() {
items := []string{
"gpio10",
"gpio1",
"gpio20",
}
sort.Sort(natural.StringSlice(items))
fmt.Println(strings.Join(items, "\n"))
}
Output: gpio1 gpio10 gpio20
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type StringSlice ¶
type StringSlice []string
StringSlice attaches the methods of Interface to []string, sorting in increasing order using natural order.
func (StringSlice) Len ¶
func (p StringSlice) Len() int
func (StringSlice) Less ¶
func (p StringSlice) Less(i, j int) bool
func (StringSlice) Swap ¶
func (p StringSlice) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.