Originally posted by Nick Cabell:
But what do I compare each last name to?
< cryptic >Other last names, of course.< /cryptic >
Would I iterate through the list as it is and compare the first item to the second, the second to the third, etc? That doesn't make sense to me how that would accomplish the sort.
The actual list sorting method (that's part of
Java -- not something you have to write yourself) takes care of iterating through the list and making sure that a sorting rule is called for every necessary pair of objects in the list. The gory details of that process are hidden from you.
For the method that you write (the one in the class that implements the interface), you are essentially defining a
sorting rule that tells the Java-supplied sorting routine what to do with any arbitrary pair of objects it happens to pull out of the list for comparing.
[ November 05, 2002: Message edited by: Michael Matola ]