How to sort items of an ArrayList?
This example shows you how we can sort items of an
ArrayList using the
Collections.sort() methods. Beside accepting the list object to be sorted we can also pass a
Comparator implementation to define the sorting behavior.
The code will output:
[black, blue, cyan, green, red, white, yellow]
[yellow, white, red, green, cyan, blue, black]