function | since v0.0-1211 | clojure.core/sorted-map-by | Edit |
(sorted-map-by comparator & keyvals)
Returns a new sorted map with supplied mappings, using the supplied comparator function.
keyvals
must be an even number of forms.
keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator.
(defn sorted-map-by
([comparator & keyvals]
(loop [in (seq keyvals)
out (PersistentTreeMap. (fn->comparator comparator) nil 0 nil 0)]
(if in
(recur (nnext in) (assoc out (first in) (second in)))
out))))