对象排序

/** OK
* @param paraMap store_ids: "20,30"
* class_ids: "75,80"
* @return List<LessonPiont> sort by point
*/
public List<LessonPiont> getLessonPointList(HashMap<String,String> paraMap){
CourseUtil util = new CourseUtil();
List<Map<String,Object>> list = util.getCourseByMyOderCT(paraMap); //get data from index
ArrayList<LessonPiont> pointList = new ArrayList<LessonPiont>();
for (Map<String,Object> map:list) {
for (String key : map.keySet()) {
LessonPiont lessonPoint = new LessonPiont();
lessonPoint.parseKey(key);
HashMap<String,Object> valueMap = (HashMap<String,Object>)map.get(key);
int point =Integer.parseInt(valueMap.get("sign_name").toString());
lessonPoint.setPoint(point);
pointList.add(lessonPoint);
}
}

Collections.sort(pointList, new Comparator<LessonPiont>(){
@Override
public int compare(LessonPiont less1, LessonPiont less2) {
if(less1.getPoint()>less2.getPoint()){
return -1;
}else{
return 1;
}
}
});
return pointList;
}
posted @ 2016-11-29 20:43  为爱奋斗不息  阅读(183)  评论(0编辑  收藏  举报