How to sort array in decreasing order in Java? Example Tutorial
It's easy to sort an array on increasing order by using Arrays.sort() method, which by default sort the array on increasing order, but if you have to sort array into decreasing order then how do you it? For example, if you have an array of Strings {"a", "b", "c"} how do you sort them into descending order? Well, if you remember, Arrays.sort() is overloaded and there is another version, which accepts a Comparator. To sort the array in decreasing order, you can simply providing a comparator which compares element in the reverse order. Thankfully there is one such Comparator already exists in JDK API, Collections.reverseOrder().
---
Java, Unix, Tibco RV and FIX Protocol Tutorial