ArrayList排序

Collections.sort(gradeclassnameList, newSortByAge());

for(GradeClassBean.ResultBean.ClassListBean student :gradeclassnameList) {

System.out.println(student.getGradeId());

}



classSortByAgeimplementsComparator {

public intcompare(Object o1,Object o2) {

GradeClassBean.ResultBean.ClassListBean s1 = (GradeClassBean.ResultBean.ClassListBean) o1;

GradeClassBean.ResultBean.ClassListBean s2 = (GradeClassBean.ResultBean.ClassListBean) o2;

returnFloat.compare(Integer.parseInt(s1.getGradeId()),Integer.parseInt(s2.getGradeId()));

}

}

你可能感兴趣的:(ArrayList排序)