Incorrect output sequence


#1

Can anyone help me to find what is wrong with the comparator code
public int compareTo(P r) {

    int result = Integer.compare(this.count,r.count);
    if (result != 0) 
        return result;
    return Integer.compare(r.index,this.index);

}