我有一份阿拉伯语单词列表。
الأحد,الاثنين,الثلاثاء,الأربعاء,الخميس,الجمعة,السبت
如何对其进行排序(按字母排序)?
更新:
如何将arrabicCollator设置为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());
}
});
已解决:
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
是一个包含setter和getter函数的类,arr_items
是一个数组if helper:
ArrayList arr_items = new ArrayList&lt;&gt;();