From d4e6648afd61205136c98fdc56cf151eb437a078 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 22 Dec 2018 18:19:29 -0200 Subject: Move external scripts to bin/. --- bin/sleepsort | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 bin/sleepsort (limited to 'bin/sleepsort') 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 -- cgit v1.2.3