Re:Java for Everything
by attheoffice on Monday December 01, 2014 @03:05AM
(#8679957)
Java 8 counterpart to you Clojure variant is actually:
coll.sort(comparing(identity(), Integer::compareTo));
Or:
coll.sort(reverseOrder())
Re:Java for Everything
by nickbauman on Monday December 01, 2014 @11:45AM
(#8682008)
Better! Still much more complex, though.
(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.