public static < T > void sort ( List < T > list , Comparator < ? super T > comparator ) { if ( list instanceof RandomAccess ) { quicksort ( list , comparator ) ; } else { List < T > copy = new ArrayList <> ( list ) ; quicksort ( copy , comparator ) ; list . clear ( ) ; list . addAll ( copy ) ; } }
Sorts the given list using the given comparator .