NaturalSort is a command line program for performing a natural sort on some given set of input. All whitespace or control characters and considered to be delimiters of items to be sorted.
To build naturalsort, issue the following command whilst in its root directory:
NaturalSort relies on
github.com/stretchr/testify for its tests, to install this dependency type:
go get -t .
testify is installed you may run the tests by typing:
go test -v -cover
To install naturalsort into your local go/bin directory type:
go install .
NaturalSort is invoked by typing
There are four command line flags that may be passed:
A path to a file to read input from when input_type is either file or gzip.
The type of input to read: (stdin | file | gzip) (default “stdin”)
A path to a file to write output to when output_type is either file or gzip.
The type of output to write: (stdout | file | gzip) (default “stdout”)
Sort input from stdin:
cat data | naturalsort
Sort input from file
naturalsort -it file -if ./data
Sort input from gzipped file
naturalsort -it gzip -if ./data.gz
Sort input and output to a file
cat data | naturalsort -ot file -of ./sorted
Sort input and output to a gzipped file
cat data | naturalsort -ot gzip -of ./sorted.gz