@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> void sort (List<T> list, Comparator<? super T> c)

Sorts the specified list according to the order induced by the specified comparator. All elements in the list must be mutually comparable using the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the list).

This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

The specified list must be modifiable, but need not be resizable.

<T>    the class of the objects in the list
list    the list to be sorted.
c    the comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be used.

ClassCastException    if the list contains elements that are not mutually comparable using the specified comparator.
UnsupportedOperationException    if the specified list's list-iterator does not support the set operation.
IllegalArgumentException    (optional) if the comparator is found to violate the Comparator contract

See also:

@implNote This implementation defers to the List.sort(Comparator) method using the specified list and comparator.