public class Item implements Comparable<Item> {
private int weight;
public Item(int w) { weight = w; }
public int compareTo(Item other) {
return other.weight - this.weight;
}
}What sort order does this produce?
- A
ascending by weight
- B
random
- C
no order
- Dcheck_circle
descending by weight
Explanation
Reversing the subtraction yields descending order.