I have a question, that i am getting a JSON response from a by calling a service, i am getting the name, location, position, email, phone number field. Each field is stored in its ArrayList. and i am showing these value in Listview.
Now i have to show the Name in sorted order, but other fields should also get arranged by corresponding name.
We can do by sorting by using Collection.sort(nameArrayList), but how other field will get affected??
how to do this in efficient way?? Any idea??
Thanks.
create a
hashMap<String name ,pojo values);now read every name and store corresponding values location, position, email, phone number into pojo object .
after inserting all values sort map by name .
wherever using hashmap to populate list , iterate over keys and value and use them
When name is repeated
better to use ArrayList with your own comparator .
go through this code snippet for more help