posted 12 years ago
You'll want to use java.util.Comparator and java.lang.Comparable. You can write a comparator to sort a java Collection in any way you see fit. You can also use the Comparator to instantiate sorted collections so you don't have to sort things all at once, they get inserted into their sorted positions at the time of insertion. Or, many classes already implement the Comparable interface so they have a "natural ordering". Strings have this capability already...