diff options
author | EuAndreh <eu@euandre.org> | 2019-04-28 13:18:49 +0000 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-04-28 13:18:49 +0000 |
commit | 4a73dca595e57751448899053cddb958c17fe75c (patch) | |
tree | 8c1a0b9d997fc4a0531559f6b7e8102deae25f74 /bin/sleepsort | |
parent | Update os-installation.sh (diff) | |
parent | Split vagrant cmds. (diff) | |
download | dotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.gz dotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.xz |
Merge remote-tracking branch 'srht/master'
Diffstat (limited to 'bin/sleepsort')
-rwxr-xr-x | bin/sleepsort | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/sleepsort b/bin/sleepsort new file mode 100755 index 0000000..ea20fcb --- /dev/null +++ b/bin/sleepsort @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Taken from: +# https://www.quora.com/What-is-the-strangest-sorting-algorithm/answer/Nipun-Ramakrishnan + +function f() { + sleep "$1" + echo "$1" +} + +while [ -n "$1" ] +do + f "$1" & + shift +done + +wait + +# example usage: +# sleepsort 5 3 6 3 6 3 1 4 7 |