Skip to content
A command line natural sort.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.org
TODO.org
data
data.gz
item.go
item_test.go
itemlist.go
itemlist_test.go
main.go
main_test.go
naturalsort.go
naturalsort_test.go
part.go
part_test.go
spec.org

README.org

NaturalSort

Introduction

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.

Building

To build naturalsort, issue the following command whilst in its root directory:

go build

Testing

NaturalSort relies on github.com/stretchr/testify for its tests, to install this dependency type:

go get -t .

Once testify is installed you may run the tests by typing:

go test -v -cover

Installing

To install naturalsort into your local go/bin directory type:

go install .

Usage:

NaturalSort is invoked by typing naturalsort.

There are four command line flags that may be passed:

-if string

A path to a file to read input from when input_type is either file or gzip.

-it string

The type of input to read: (stdin | file | gzip) (default “stdin”)

-of string

A path to a file to write output to when output_type is either file or gzip.

-ot string

The type of output to write: (stdout | file | gzip) (default “stdout”)

Examples:

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
You can’t perform that action at this time.