I created an implementation Comparator<Entity>, but when I use this comparator to sort Array<Entity>. I will get java.lang.NullPointerExceptionit because when I map the object to static collections that are already deleted. Now my problem is that I do not know what to return to skip the comparison method.
public class CustomComparator implements Comparator<Entity> {
public int compare(Entity e1, Entity e2) {
if( e1== null || e2 == null) {
return
}
Vector2 e1Pos = Mapper.transform.get(e1).position;
Vector2 e2Pos = Mapper.transform.get(e2).position;
}
}
user4822216
source
share