In the contacts class (implements actionListener) I have a JList that contains objects (elements from a file). There are sorting buttons, each button has an actionListener
by firstname
by last name
by city
The sorting is done by the elements of objects.
the user should give the first and last name and city for a contact. How to do the sorting ??
And to put those into the list I used this code:
Map<String, contacts> ma = readFromFile();
for (Map.Entry<String, contacts> entry : ma.entrySet()) {
contacts c = (contacts) entry.getValue();
d.addElement(c.getLastName() + "" + c.getFirstName() + "" + c.getCity());
}
How to do the sorting ?? plz help