Skip to content

Instantly share code, notes, and snippets.

@timendum
Forked from ijanos/sleepsort.bash
Created July 27, 2011 10:02
Show Gist options
  • Select an option

  • Save timendum/1109051 to your computer and use it in GitHub Desktop.

Select an option

Save timendum/1109051 to your computer and use it in GitHub Desktop.

Revisions

  1. @ijanos ijanos created this gist Jun 15, 2011.
    19 changes: 19 additions & 0 deletions sleepsort.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/bash

    # Sleep sort
    # http://dis.4chan.org/read/prog/1295544154


    function f() {
    sleep "$1"
    echo "$1"
    }
    while [ -n "$1" ]
    do
    f "$1" &
    shift
    done
    wait

    # example usage:
    # ./sleepsort.bash 5 3 6 3 6 3 1 4 7