posted 16 years ago
The classes, which implement the Comparable interface, impose natural order. By implementing Comparable, sorting an array of objects or a collection (List etc) is as simple as:
For classes that don�t implement Comparable interface, or when one needs even more control over ordering based on multiple attributes, a Comparator interface should be used.
For advanced users, The Apache's BeanComparator can simplify things further.