Guava allows us to sort an array by chaining ordering, as shown in the example below:
List cars = Arrays.asList(
new Car("Dacia", 21000),
new Car("Audi", 30000),
new Car("Fiat", null));
Ordering ordering = Ordering
.natural()
.nullsFirst()
.onResultOf(new Function() {
@Override
public Comparable apply(Car car) {
return car.price;
}
});