how-to

Arrays

How to sort array elements

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 );

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

The output is:

[Fight, Four, One, Three, Two]

NOTE: This is the most simpest variant of array sorting.