Sleep Sort

4chan上面有人發明了新的sorting方法:

#!/bin/bash
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

簡單的說,替每個input的數字建立一個thread,thread中就sleep該數字的秒數後,印出該數字。這真的太天才了 XDD

出處:http://dis.4chan.org/read/prog/1295544154

原討論串也是充滿各式各樣笑點,強烈推薦閱讀

忙碌中看到這個讓我笑到翻掉阿 XDD

Advertisements