comparator
/** * 比较器,用于帮派战力排在前面 * */ private class BangValueCompare implements Comparator<UserInfo> { @Override public int compare(UserInfo lhs, UserInfo rhs) { UserInfo sh1 = (UserInfo) lhs; UserInfo sh2 = (UserInfo) rhs; if (sh1 == null) { return 1; } if (sh2 == null) { return -1; } if (sh1.getValue() > sh2.getValue()) { return -1; } else if (sh1.getValue() == sh2.getValue()) { return 0; } else { return 1; } } } BangValueCompare comparator = new BangValueCompare(); Collections.sort(mChatUserInfoList, comparator);