gpt4 book ai didi

android - 在android中对阿拉伯语单词进行排序

转载 作者:太空狗 更新时间:2023-10-29 14:12:21 28 4
gpt4 key购买 nike

<分区>

我有一个阿拉伯语单词列表。

الأَحَد, الاِثنَين, الثُّلاثاء, الأَربِعاء, الخَميس, الجُمعة,السَّبت

如何排序(按字母排序)?


更新:

如何将 arrabicCollat​​or 设置为 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 是一个数组,如果 helper :

ArrayList arr_items = new ArrayList<>();

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com