The fn->comparator
call should be lifted:
(sort (fn [x y] ((fn->comparator comp) (keyfn x) (keyfn y))) coll)
(let [comparator (fn->comparator comp)]
(sort (fn [x y] (comparator (keyfn x) (keyfn y))) coll))
Also, fn->comparator
is again called on the function in {{sort}}, not sure how to avoid that unless we copy the sort code into {{sort-by}}.