diff options
author | EuAndreh <eu@euandre.org> | 2018-03-23 20:38:44 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2018-03-23 20:49:09 -0300 |
commit | 4e734232c611890f616194ed5cfade2549e4491b (patch) | |
tree | 38e74c5f28aaa8ecc8c6cbff7836d919c8fa7a1b /scripts/sleepsort | |
parent | Initial commit: add git-crypt .gitattributes file (diff) | |
download | dotfiles-4e734232c611890f616194ed5cfade2549e4491b.tar.gz dotfiles-4e734232c611890f616194ed5cfade2549e4491b.tar.xz |
Initial commit: now public (again)
Diffstat (limited to 'scripts/sleepsort')
-rwxr-xr-x | scripts/sleepsort | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/sleepsort b/scripts/sleepsort new file mode 100755 index 0000000..ea20fcb --- /dev/null +++ b/scripts/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 |