알고리즘

compareTo 비교

leeeehhjj 2023. 4. 6. 01:34
public int compareTo(Other t) {
	return this.cnt - t.cnt;
}

음수 : other이 더 크다

0 : 같다

양수 : this가 더 크다

-> 오름차순 정리

 

public int compareTo(Other t) {
	return t.cnt - this.cnt;
}

-> 내림차순 정리