接口comparator:util包,int compare(T o1,T o2){o1.
compareTo(o2)}
接口comparable:lang包,int
compareTo(T o)
集合
接口collection:list、set等
集合
操作类collections:操作集合,比如排序collections.sort(collection,comparator)等
Collections.sort(hdList, new Comparator() {
public int compare(Object a, Object b) {
double orderA = ((HotelDistance) a).getDistance();
double orderB = ((HotelDistance) b).getDistance();
double d = orderA - orderB;
return d<0?-1:(d==0?0:1);
}
});