how-to

Arrays

How to sort array elements in descenting order

For sorting array elements use class java.util.Arrays. That class contains static methods for work with arrays.

String[] array = { "One", "Two", "Three", "Four", "Fight" };

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

System.out.println( Arrays.toString( array ) );

For descending items sorting use existed comparator Collections.reverseOrder().

The output is:

[Two, Three, One, Four, Fight]