Posted By:
Stephen_McConnell
Posted On:
Wednesday, January 29, 2003 04:56 AM
One of the cool things about the Collections API's is you can use the static method in the
java.util.Collections class to sort an ArrayList.
You need to create a class that implements the java.util.Comparator interface. It has two methods compare(Object a, Object b) and equals(Object a) that need to be implemented. You write the code that
does the type of comparison you need and then call the static method on java.util.Collections.sort(List list, Comparator compClass); and it will do your sort for you. ArrayList extends the List interface, so you are ok there.
Check out the JavaDoc for these classes for specifics and a basic example.
Hope this helps
Stephen McConnell