aboutsummaryrefslogtreecommitdiff
path: root/bin/sleepsort
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2019-04-28 13:18:49 +0000
committerEuAndreh <eu@euandre.org>2019-04-28 13:18:49 +0000
commit4a73dca595e57751448899053cddb958c17fe75c (patch)
tree8c1a0b9d997fc4a0531559f6b7e8102deae25f74 /bin/sleepsort
parentUpdate os-installation.sh (diff)
parentSplit vagrant cmds. (diff)
downloaddotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.gz
dotfiles-4a73dca595e57751448899053cddb958c17fe75c.tar.xz
Merge remote-tracking branch 'srht/master'
Diffstat (limited to 'bin/sleepsort')
-rwxr-xr-xbin/sleepsort20
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