标签:
compareTo必须是两个对象之间的比较
private void businessSort(List<WxDailyBusinessInfo> wxDailyBusinessInfo) {
//排序前 for (int i = 0; i < wxDailyBusinessInfo.size(); i++) { System.out.println(new Gson().toJson(wxDailyBusinessInfo.get(i))); System.out.println("---------------"); } Collections.sort(wxDailyBusinessInfo, new Comparator<WxDailyBusinessInfo>() { @Override public int compare(WxDailyBusinessInfo o1, WxDailyBusinessInfo o2) { return o1.getDistance().compareTo(o2.getDistance()); } }); System.out.println("***************排序后************"); for (int i = 0; i < wxDailyBusinessInfo.size(); i++) { System.out.println(new Gson().toJson(wxDailyBusinessInfo.get(i))); System.out.println("---------------"); } }
标签:
原文地址:http://www.cnblogs.com/dashuai01/p/5001473.html