Go to file
yafox 4c2a91533d
initial commit
2020-11-24 20:54:17 +00:00
LICENSE initial commit 2020-11-24 20:54:17 +00:00
README initial commit 2020-11-24 20:54:17 +00:00
makefile initial commit 2020-11-24 20:54:17 +00:00
shsort.sh initial commit 2020-11-24 20:54:17 +00:00
sloc.sh initial commit 2020-11-24 20:54:17 +00:00

README

shsort
======

a recursive quicksort in pure posix shell script using any arbitrary function
or command capable of parsing a comparison expression and outputing "yes" or
"no."  (e.g., anything that takes a string in the form of "1 > 3" as a command
line argument and echoes "no" and takes "1 < 3" and echoes "yes".)

34 SLOC.

usage: shsort [-r] <comparator command> [<list>]

shsort expects a newline delimited list of elements to sort.  the list may be
passed via stdin in or on the command line as the <list> argument.

the comparator command is used as-is and may be a string including flags.

for example:

    $ printf "2.9\n1.2\n3.4\n2.1\n2.1-rc0\n2.12" | shsort "vercmp -f default"
    3.4
    2.12
    2.9
    2.1
    2.1-rc0
    1.2

`-r` reverses the sort order:

    $ printf "2.9\n1.2\n3.4\n2.1\n2.1-rc0\n2.12" | shsort -r "vercmp -f default"
    1.2
    2.1-rc0
    2.1
    2.9
    2.12
    3.4