In my code I want to sort the contacts by their firstname, so I wrote the below method which is not working for me. Actually this code instead of giving me a sorted contact list it is giving me a normal unordered contactlist
public Set<Contact> sortContacts() {
Set<Contact> sortedContacts = contactList.stream().sorted((c1, c2) -> c1.firstName.compareTo(c2.firstName)).collect(Collectors.toSet());
return sortedContacts;
}