James Dekker wrote:(1) Am I doing the right thing? When a comparison = 0, it returns as -2. Is this correct behavior because I always thought it to be between -1,0,1.
THe return value is never guaranteed to be -1, 0 or 1. All you know is there are three outcomes: smaller than 0, 0 or larger than 0. -1 and 1 are just two specific cases, but -2 will be treated in exactly the same way as -1.
(2) Should I be using the comparator?
You should use compareTo which belongs to Comparable. Comparator's method is called compare. So in this case your class should implement CreditCardTransactionDetail, and Comparator is not needed. (I think Paul mixed up Comparable and Comparator.)
You should only use Comparator if:
1) your class doesn't implement Comparable.
2) you want a different sort order.