Sort Arabic words in android
I have a list of Arabic words.
الأ َ ح د د, الاثن َ ين, الث ُّ لاثاء, الأ َ ربعاء, الخ َ ميس, الج ُ معة, الس َّ بت
How to sort it (sort alphabetically)?
updated:
how can i set arrabicCollator in Collections?
Locale arrabic= new Locale("ar");
Collator arrabicCollator = Collator.getInstance(arrabic);
Collections.sort(arr_items, new Comparator<Helper>() {
@Override
public int compare(Helper one, Helper two) {
// TODO Auto-generated method stub
return one.getTitle().compareTo(two.getTitle());
}
});
solved:
Locale arabic = new Locale("ar");
final Collator arabicCollator = Collator.getInstance(arabic);
Collections.sort(arr_items, new Comparator<Helper>() {
@Override
public int compare(Helper one, Helper two) {
// TODO Auto-generated method stub
return arabicCollator.compare(one.getTitle(), two.getTitle());
}
});
helper
is a class that includes setter and getter functions, and arr_items
is an array if the helper:
ArrayList arr_items = new ArrayList <> ();
+3
source to share