/* This class implements a function to compare two objects to provide an ordering. In this case, the two objects to be compared must be two Integers, and this function just uses their natural ordering, but you could write a new function that applies some different type of ordering if desired. */ import java.util.Comparator; public class IntComparator implements Comparator { public int compare(Object o1, Object o2) throws ClassCastException { int priority1 = ((Integer)o1).intValue(); int priority2 = ((Integer)o2).intValue(); return compare(priority1, priority2); } public int compare(int val1, int val2) { if (val1 < val2) return -1; else if (val1 > val2) return +1; else return 0; } }