在android中排序阿拉伯语单词

时间:2014-10-02 16:14:50

标签: android

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

  

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

如何对其进行排序(按字母排序)?


更新:

如何将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是一个数组if helper:

  

ArrayList arr_items = new ArrayList&lt;&gt;();

1 个答案:

答案 0 :(得分:1)

你需要使用Collat​​or类。检查sdk document。另请查看此SO answer