list排序:order

list排序:

//对list排序
@SuppressWarnings("rawtypes")
public void order(List<Room> list){
Collections.sort(list,new Comparator<Room>() {
@Override
public int compare(Room o1, Room o2) {
String str1=o1.getRname()==null?"0":o1.getRname();
String str2=o2.getRname()==null?"0":o2.getRname();
int num =Integer.valueOf(str1).compareTo(Integer.valueOf(str2));
return num;
}
});
}

posted @ 2016-06-02 20:54  Kevin_Zhou_9  阅读(528)  评论(0编辑  收藏  举报