clojure.core/sort-by 为每对比较评估 keyfn。当 keyfn 计算成本很高时,这是浪费的。
`
user=> (def keyfn-calls (atom 0))
'user/keyfn-calls
user=> (defn keyfn [x] (do (swap! keyfn-calls inc) x))
'user/keyfn
user=> @keyfn-calls
0
user=> (sort-by keyfn (repeatedly 10 rand))
(0.1647483850582695 0.2836687590331822 0.3222305842748623 0.3850390922996001 0.41965440953966326 0.4777580378736771 0.6051704988802923 0.659376178201709 0.8459820304223701 0.938863131161208)
user=> @keyfn-calls
44
`