D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Sleep sort

 

Came across this yesterday. Definitely not the fastest search
algorithm but probably the nicest I've ever seen.

#!/bin/bash
function f() {
    sleep "$1"
    echo "$1"
}
while [ -n "$1" ]
do
    f "$1" &
    shift
done
wait

Call with integers to be sorted as arguments.

Source: http://dis.4chan.org/read/prog/1295544154 which also has some
nice improvements.

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq