Sorting and searching Lists

Utilities to perform sorting and searching for Lists have the same names and signatures as those for sorting arrays of objects, but are static methods of Collections instead of Arrays. Heres an example, modified from ArraySearching.java:

The use of these methods is identical to the ones in Arrays, but youre using a List instead of an array. Just like searching and sorting with arrays, if you sort using a Comparator, you must binarySearch( ) using the same Comparator.

This program also demonstrates the shuffle( ) method in Collections, which randomizes the order of a List.