• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

LICENSEH A D18-Apr-20191.5 KiB

README.mdH A D18-Apr-20192.1 KiB

natsort.goH A D18-Apr-20191.8 KiB

natsort_test.goH A D18-Apr-20193 KiB

README.md

1# natsort: natural strings sorting in Go
2
3This is an implementation of the "Alphanum Algorithm" by [Dave Koelle][0] in Go.
4
5[![GoDoc](https://godoc.org/facette.io/natsort?status.svg)](https://godoc.org/facette.io/natsort)
6
7## Usage
8
9```go
10package main
11
12import (
13    "fmt"
14    "strings"
15
16    "facette.io/natsort"
17)
18
19func main() {
20    list := []string{
21        "1000X Radonius Maximus",
22        "10X Radonius",
23        "200X Radonius",
24        "20X Radonius",
25        "20X Radonius Prime",
26        "30X Radonius",
27        "40X Radonius",
28        "Allegia 50 Clasteron",
29        "Allegia 500 Clasteron",
30        "Allegia 50B Clasteron",
31        "Allegia 51 Clasteron",
32        "Allegia 6R Clasteron",
33        "Alpha 100",
34        "Alpha 2",
35        "Alpha 200",
36        "Alpha 2A",
37        "Alpha 2A-8000",
38        "Alpha 2A-900",
39        "Callisto Morphamax",
40        "Callisto Morphamax 500",
41        "Callisto Morphamax 5000",
42        "Callisto Morphamax 600",
43        "Callisto Morphamax 6000 SE",
44        "Callisto Morphamax 6000 SE2",
45        "Callisto Morphamax 700",
46        "Callisto Morphamax 7000",
47        "Xiph Xlater 10000",
48        "Xiph Xlater 2000",
49        "Xiph Xlater 300",
50        "Xiph Xlater 40",
51        "Xiph Xlater 5",
52        "Xiph Xlater 50",
53        "Xiph Xlater 500",
54        "Xiph Xlater 5000",
55        "Xiph Xlater 58",
56    }
57
58    natsort.Sort(list)
59
60    fmt.Println(strings.Join(list, "\n"))
61}
62```
63
64Output:
65
66```
6710X Radonius
6820X Radonius
6920X Radonius Prime
7030X Radonius
7140X Radonius
72200X Radonius
731000X Radonius Maximus
74Allegia 6R Clasteron
75Allegia 50 Clasteron
76Allegia 50B Clasteron
77Allegia 51 Clasteron
78Allegia 500 Clasteron
79Alpha 2
80Alpha 2A
81Alpha 2A-900
82Alpha 2A-8000
83Alpha 100
84Alpha 200
85Callisto Morphamax
86Callisto Morphamax 500
87Callisto Morphamax 600
88Callisto Morphamax 700
89Callisto Morphamax 5000
90Callisto Morphamax 6000 SE
91Callisto Morphamax 6000 SE2
92Callisto Morphamax 7000
93Xiph Xlater 5
94Xiph Xlater 40
95Xiph Xlater 50
96Xiph Xlater 58
97Xiph Xlater 300
98Xiph Xlater 500
99Xiph Xlater 2000
100Xiph Xlater 5000
101Xiph Xlater 10000
102```
103
104[0]: http://davekoelle.com/alphanum.html
105