📅  最后修改于: 2022-03-11 14:52:39.383000             🧑  作者: Mango
List 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;
}