I want to sort a collection by multiple fields (some of them in descending order) using Apache Commons CompareToBuilder
Ie:
Collections.sort(pizzas, new Comparator<Pizza>() {
@Override
public int compare(Pizza p1, Pizza p2) {
return new CompareToBuilder().append(p1.size, p2.size).append(p1.nrOfToppings, p2.nrOfToppings).append(p1.name, p2.name).toComparison();
}
});
The default behavior for null values (ie. z, b, a, 1, null) is still true? Or null values comes first in this case?