We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46d6287 commit d5af2abCopy full SHA for d5af2ab
Pair/Pair.java
@@ -13,8 +13,9 @@ public boolean equals(Object another){
13
return this.first.equals(otherPair.first) && this.second.equals(otherPair.second);
14
}
15
public int compareTo(Pair<S,T> another){
16
- if(this.second.compareTo(another.second) == 0) return this.first.compareTo(another.first);
17
- else return this.second.compareTo(another.second);
+ Comparator<Pair<S,T>> comp1 = Comparator.comparing(Pair::getFirst);
+ Comparator<Pair<S,T>> comp2 = comp1.thenComparing(Pair::getSecond);
18
+ return comp2.compare(this, another);
19
20
public int hashCode(){
21
return first.hashCode() * 10007 + second.hashCode();
0 commit comments