function | since v0.0-927 | clojure.core/sort-by | Edit |
(sort-by keyfn coll)
(sort-by keyfn comp coll)
Returns a sorted sequence of the items in coll
, where the sort order is
determined by comparing (keyfn item)
.
comp
can be boolean-valued comparison function, or a -/0/+ valued comparator.
comp
defaults to compare
.
Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). Comp can be boolean-valued comparison function, or a -/0/+ valued comparator. Comp defaults to compare.
(defn sort-by
([keyfn coll]
(sort-by keyfn compare coll))
([keyfn comp coll]
(sort (fn [x y] ((fn->comparator comp) (keyfn x) (keyfn y))) coll)))