//QuadraticComparator.java //what does sorting do to Quadratics? //Collections.sort(myQuadraticList); //***runtime error. //***there is no "natural ordering" for user-defined classes. //***must specify how quadratic objects are compared with a Comparator. //enables: Collections.sort(collectionObject,new QuadraticComparator()); import java.util.*; public class QuadraticComparator implements Comparator { //implementing the Comparator interface requires the compare method //return 0 if equal, positive if a>b, negative if a q2.getA()) return 1; else if (q1.getA() < q2.getA()) return -1; else if (q1.getB() > q2.getB()) return 1; else if (q1.getB() < q2.getB()) return -1; else if (q1.getC() > q2.getC()) return 1; else if (q1.getC() < q2.getC()) return -1; else return 0; } }