Sorting an int array from highest to lowest

arrays, java, sorting

Solution

If you use an `Integer[]` instead of `int[]`, then you can pass a `Comparator` as 2nd argument to the sort method. To impose reverse ordering, you can make use of `Collections.reverseOrder()` method:

Arrays.sort(arr, Collections.reverseOrder());

Problem

So I just learned about the `Arrays.sort(arrayName);` and applied it in a project of mine but I found it sorts from lowest to highest. Is there anyway to have it do the opposite? (I don't think I need to post the code in question but if it is needed I'll post it).

Original source