A GoLang library to sort slices of strings in Natural Sort order and based on the numerical weightage.
-
Get the package:
go get github.com/wasim-nihal/gonatsort
-
Import the package in the code
package main import ( "fmt" "sort" "github.com/wasim-nihal/gonatsort" ) func main() { arr1 := []string{"bar2", "foo", "foo123", "foo2", "bar001"} sort.Stable(gonatsort.NatSorter(arr1)) // Output: [bar001 bar2 foo foo2 foo123] fmt.Println(arr1) }
This project is licensed under the Apache-2.0 license License. See the LICENSE file for details.