Archive for September 2011
New Sort? (kind of)
One doesn’t find a new sorting algorithm floating around the internet very often, but here’s one that I found that’s actually kind of neat.
It’s not really very practical, but it’s still very fun. It’s quite simple. For each element of the array, you fork a new process which sleeps it’s value in seconds then displays that number. Repeat for the entire array.
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait