You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
yafox 4c2a91533d
initial commit
3 years ago
LICENSE initial commit 3 years ago
README initial commit 3 years ago
makefile initial commit 3 years ago
shsort.sh initial commit 3 years ago
sloc.sh initial commit 3 years ago

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