Assume I have a user defined Java class called Foo such as:
public class Foo { private String aField; @Override public String toString() {
Collections.sort(fooList, new Comparator() { public int compare(Foo f1, Foo f2) { return f1.toString().compareTo(f2.toString()); } });
Assuming that toString never returns null and that there are no null items in the list.