Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.19 KB

README.md

File metadata and controls

34 lines (26 loc) · 1.19 KB

gonatsort

A GoLang library to sort slices of strings in Natural Sort order and based on the numerical weightage.

Go Reference Build Security Check Go Report Card

Usage

  1. Get the package:

    go get github.com/wasim-nihal/gonatsort
  2. 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)
    }
    

License

This project is licensed under the Apache-2.0 license License. See the LICENSE file for details.