A simple way to generate a comparator in Java