static class Node implements Comparable<Node> {
int end;
int cost;
public Node(int end, int cost) {
this.end = end;
this.cost = cost;
}
@Override
public int compareTo(Node o){
return Integer.compare(this.cost, o.cost);
//return this.cost - o.cost; // 오름차순
// return 값이 음수나 0이면 유지, 양수이면 객체 swap
}
}
Collections.sort(nodeList);
Collections.sort(nodeList, new Comparator<Node>() {
@Override
public int compare(Node o1, Node o2) {
return Integer.compare(o1.cost, o2.cost);
}
})