List如何按String类型的属性进行排序

1、代码

Collections.sort(stus,new Comparator<Student>() {

            @Override
            public int compare(Student o1, Student o2) {
                // TODO Auto-generated method stub
                if(o1.getName().compareTo(o2.getName()) >= 1){   //记得要写上>=,而不是大于
                    return 1;
                }else{
                    return -1;
                }
            }
        });
原文地址:https://www.cnblogs.com/wwssgg/p/14511348.html