i have array list of country objects (name property is in arabic) I'm retrieving from a webservice, how can i sort this list based on the name property, can you please help me regards,
Asked
Active
Viewed 159 times
1 Answers
0
Sort List
alphabetically:
java.util.Collections.sort(listOfCountryNames);
or sort ArrayList
:
Collections.sort(list, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});

Aman Grover
- 1,621
- 1
- 21
- 41
-
country is an object having many properties – eshteghel company Sep 09 '16 at 11:26
-
then you have to make your own comparator based on your choice – Aman Grover Sep 09 '16 at 11:27