This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
No offense, but I would never use anything from that code:
1) That Comparer interface is exactly the same as the old non-generic java.util.Comparator interface.
2) That Comparable interface is exactly the same as the old non-generic java.lang.Comparable interface.
3) That sorting functionality already exists in java.util.Arrays. To sort in reverse order, you can use one of the two reverseOrder methods in java.util.Collections.
That compare method is 100% identical to the implementation of reverseOrder(). That's also a singleton which makes it slightly more efficient - no matter how many times you call the method, only one object is created.
Joined: Oct 13, 2005
I hadn’t noticed that reverseOrder creates a Comparator rather than reversing the list