I want to implement a java.util.Comparator
with Long
:
new Comparator<Long>() {
public int compare(Long l1, Long l2) {
// (*)
}
}
I have a solution with operator ?:
:
return l1==l2 ? 0 : (l1>l2 ? 1 : -1);
But I wonder if there is any other way to implement it.
(I was trying return (int)(l1-l2)
, but it's incorrect).