Sorting algorithms/Sleep sort: Difference between revisions

Added clojure core.async example
m (→‎{{header|REXX}}: added a section header comment (only works with ...), changed/add comments and indentations, added whitespace.)
(Added clojure core.async example)
Line 192:
}
}</lang>
 
=={{header|Clojure}}==
Using core.async
<lang clojure>(ns sleepsort.core
(require [clojure.core.async :as async :refer [chan go <! <!! >! timeout]]))
 
(defn sleep-sort [l]
(let [c (chan (count l))]
(doseq [i l]
(go (<! (timeout (* 1000 i)))
(>! c i)))
(<!! (async/into [] (async/take (count l) c)))))</lang>
<lang clojure>(sleep-sort [4 5 3 1 2 7 6])
;=> [1 2 3 4 5 6 7]</lang>
=={{header|CoffeeScript}}==
{{works_with|node.js}}
Anonymous user