I am trying to sort a bunch of numbers and have the following code:
//sort possible targets based on distance
Collections.sort(allPossibleTargets, new Comparator<NPD2>() {
@Override
public int compare(NPD2 o1, NPD2 o2) {
if (o1 == null && o2 == null)
return 0;
if (o1 == null && o2 != null)
return 1;
if (o1 != null && o2 == null)
return -1;
return o1.getNpd().getDistance() < o2.getNpd().getDistance() ? -1 : 1;
}
});
However, I get the above exception. Please help. Thanks.