posted 19 years ago
Kyle,
It is both. I have a master list that contains many individuals. Each individual, in turn, can contain zero or more addresses. I would like to sort the master list.
Master List 1------>* Individual 1------>* addresses
Individual contains last name, first name, middle name, gender, date of birth and a list of addresses.
Address contains street number, street name, apartment, city, state ,zip
At runtime, a user can specify the fields to be sorted and the sort order.
Say a user wants to sort the master list in this order: last name, first name, city, and state.
If last name and first name of two individual objects are different, compareTo() method will return either negative or positive number.
If they happen to be the same, then city and state in the address objects are compared.