From 4e734232c611890f616194ed5cfade2549e4491b Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 23 Mar 2018 20:38:44 -0300 Subject: Initial commit: now public (again) --- scripts/sleepsort | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/sleepsort (limited to 'scripts/sleepsort') 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 -- cgit v1.2.3