Sorts strings with natural order for version numbers.
Go to file
Laurence Withers 9b0ccf41c2 Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
LICENSE Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
README.md Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
example_test.go Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
go.mod Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
sort.go Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00
unit_test.go Initial commit; import from github.com/lwithers/pkg 2020-01-03 14:03:25 +00:00

README.md

src.lwithers.me.uk/go/versionsort

GoDoc

This package provides a Go implementation of the venerable C function versionsort(3). This lets you sort strings containing natural numbers, such as versions. It understands that 1.12 is greater than 1.6, for example.

Example of usage:

	input := []string{"1.12", "1.24", "1.1", "1.6"}
	versionsort.Strings(input)
	fmt.Println(input)
	// Output: [1.1 1.6 1.12 1.24]