It's easy to sort an object array in decreasing or reverse order, just provide the Comparator with opposite order. You can even use Collections.reverseOrder() if you want to sort array in the decreasing order, which returns a reverse Comparator to sort objects in the order opposite of their natural ordering defined by the compareTo() method. Unfortunately, for a primitive array, there is no direct way to sort in descending order. The Arrays.sort() method which is used to sort a primitive array in Java doesn't accept a boolean to sort the primitive array in reverse order. You might have seen the error "no suitable method found for sort(int[],comparator<object>)" which occurs when programmers try to call the Arrays.sort() method by passing reverse Comparator defined by Collection.reverseOrder(). That will work fine with Integer array but will not work with an int array. The only way to sort a primitive array in descending order is, first sort the array in ascending order and then reverse the array in place as shown here. This is also true for two-dimensional primitive arrays.
Read more »
