Android:根据字符串字段对数组对象进行排序,并考虑Locale

时间:2016-07-23 12:30:43

标签: android sorting

这是我的朋友对象:

public class Friend {

public String firstname;
public String lastname;
...

我想根据 firstname 字段对Friend ArrayList进行排序,并使用对帐号重音进行排序

ArrayList<Friend> mFriends;
...

// Sort friend by firstname
Collections.sort(mFriends, new Comparator<Friend>() {
        @Override
        public int compare(Friend o1, Friend o2) {
            return o1.firstname.compareTo(o2.firstname);
        }
});

那么,我该如何添加重音条件?

1 个答案:

答案 0 :(得分:0)

我不清楚,但是Collat​​or能够与重音进行比较 见:How to compare non english characters with accents