Skip to content

Instantly share code, notes, and snippets.

@clojens
Forked from pepijndevos/pigeonhole_sort.clj
Created September 3, 2013 20:26
Show Gist options
  • Select an option

  • Save clojens/6429085 to your computer and use it in GitHub Desktop.

Select an option

Save clojens/6429085 to your computer and use it in GitHub Desktop.

Revisions

  1. @pepijndevos pepijndevos created this gist Jan 11, 2011.
    8 changes: 8 additions & 0 deletions pigeonhole_sort.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    (ns pigeonhole-sort)

    (defn int-sort [s]
    (let [listmap (reduce #(update-in
    (update-in %1 [%2] (fnil inc 0))
    [:max] max %2) {:max 0} s)]
    (mapcat #(repeat (get listmap % 0) %)
    (range (inc (:max listmap))))))