I have a method:
public List sortStuff(List toSort) {
java.util.Collections.sort(toSort);
return toSort;
}
T
Sorting Generic Collections
There are two sorting functions defined in this class, shown below:
public static > void sort(List list);
public static void sort(List list, Comparator super T> c);
Neither one of these is exactly easy on the eyes and both include the wildcard (?) operator in their definitions. The first version accepts a List only if T extends Comparable directly or a generic instantiation of Comparable which takes T or a superclass as a generic parameter. The second version takes a List and a Comparator instantiated with T or a supertype.