Skip to content

Instantly share code, notes, and snippets.

@becojo
Created December 25, 2013 15:07
Show Gist options
  • Save becojo/8124062 to your computer and use it in GitHub Desktop.
Save becojo/8124062 to your computer and use it in GitHub Desktop.
Insertion sort
(defn insert [coll, n]
(let [parts (split-with (partial > n) coll)]
(concat (first parts) [n] (last parts))))
(defn insertion-sort [coll]
(reduce (fn [sorted item]
(insert sorted item)) nil coll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment