Corrected the comparator to check on keys when the values are equal. Doh!