I have a object
Class Employee(id, name, city){ };
List<Employee> list1 = new ArrayList();
list1.add(new Employee(2, "Abc", "eJ"));
list1.add(new Employee(3, "Zec", "eJ");
list1.add(new Employee(4, "Cec", "eJ"));
list1.add(new Employee(5, "Abc", "Ab"));
list1.add(new Employee(6, "Abc", "Ze"));
i need to sort Employee object based on name even along with city
"Abc","Ab"
"Abc","eJ"
"Abc","Ze"
"Cec","eJ"
"Zec", "eJ"
but i am getting sorting like - city not getting ordered along with name.
"Abc","eJ" - city not ordered here
"Abc","Ab"
"Abc","Ze"
"Cec","eJ"
"Zec", "eJ"
Anyone knows, plz help me wat is the issue with comparator?