Java List -Komparator Lambda
List<Target> list = new List<>();
list.sort(Comparator.comparingInt(target -> distanceTo(target.getPosition())));
public int distanceTo(Point position) {
int distance = 0;
distance += Math.abs(position.x - this.getPosition().x);
distance += Math.abs(position.y - this.getPosition().y);
return distance;
}
Im_Arxus