6 ms·
Or in Clojure, it's (sort #(compare %1 %2) coll) To reverse it (sort #(compare %2 %1) coll) Where coll is the collection you want to sort. Same caveat appli
by nickbauman 12y ago
Or in Clojure, it's
(sort #(compare %1 %2) coll)
To reverse it
(sort #(compare %2 %1) coll)
Where coll is the collection you want to sort. Same caveat applies with:
(reverse coll)
Try as I might I can't get Clojure to bench slower than its comparative Java. I see no reason to program in Java anymore wherever possible.
- attheoffice 12y agoJava 8 counterpart to you Clojure variant is actually: coll.sort(comparing(identity(), Integer::compareTo)); Or: coll.sort(reverseOrder())
- nickbauman 12y agoBetter! Still much more complex, though.