Sorting Java Collections

Sorting Java Collections

Sorting collections is a common task that Java developers deal with on a daily bases. The Java Collections class provides us with two sort() methods to sort all collections that implement the List interface.

Sorting Primitive Types & Strings

In the example below, we will create a list with ten random integers and sort the list using the sort() method, which takes in a List of objects.