I am trying to sort my custom class array-list using Collections.sort by declaring my own anonymous comparator. But the sort is not working as expected.
My code is
As indicated by Adam, you can use return (lhs.Name.compareTo(rhs.Name)); likeso:
return (lhs.Name.compareTo(rhs.Name));
Collections.sort(arrlstContacts, new Comparator() { public int compare(Contacts lhs, Contacts rhs) { return (lhs.Name.compareTo(rhs.Name)); } });