JAVA Collections.sort 匿名内部内排序

//酒店排序
Collections.sort(hotelGroups, new Comparator(){
public int compare(Object o1,Object o2) {
    SingleProductHotel singleProductHotel1 = 
	(SingleProductHotel)(((SingleProductGroup)o1).getSingleProduct());
    SingleProductHotel singleProductHotel2 = 
	(SingleProductHotel)(((SingleProductGroup)o2).getSingleProduct());
    if(null != o1 && null != singleProductHotel1.getProviderMember().getName() &&
       null != o2 && null != singleProductHotel2.getProviderMember().getName() ){
       return singleProductHotel1.getProviderMember().getName()
	   .compareTo(singleProductHotel2.getProviderMember().getName());
    }
    return 0;
}
});

 

你可能感兴趣的:(Collections)