我有这个用户类
public class User {
public String userName;
public int highScore = 0;
public static ArrayList<User> userList = new ArrayList<User>(5);
public User(String name, int score) {
this.userName = name;
this.highScore = score;
userList.add(this);
Collections.sort(userList, new Comparator<User>() {
@Override
public int compare(User lhs, User rhs) {
return lhs.highScore-rhs.highScore;
}
});
}
}
用户对象具有属性名称和分数。我想根据用户的分数对我的列表进行排序。