Assume I have a user defined Java class called Foo such as:
public class Foo { private String aField; @Override public String toString() {
If you want the collection to remain sorted, rather than sorting it at specific points, you could put it in a TreeSet with a defined Comparator. Otherwise, I'd use the Collections.sort method already mentioned by Yuval.