CPSC 2150 - DAY 17 OCTOBER 25, 2016 ================================================================================ JAVA GENERIC COLLECTIONS ------------------------ .ex. List and ArrayList Sort a queue void sort(Comparator order) .Sorts this queue according to the ordering provided by compare method from order .Updates this .Requires: [the relation computed by order.compare is a total preorder] .Ensures: this = [#this ordered by the relation computed by order.compare] public interface Comparator { /** * Returns a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ int compare(T o1, T o2); } A class that implements Comparator is usually a nested class.