對列表進行排序
阿新 • • 發佈:2019-02-14
private void sortList() {
//sort
Comparator itemComparator = new Comparator() {
public int compare(PanYuanItemBean a, PanYuanItemBean b) {
/方法一/
//return a.getDistance().compareTo(b.getDistance());
double x = Double.parseDouble(a.getDistance()); double y = Double.parseDouble(b.getDistance()); return (int) (x - y); } }; //方法二對小數有小誤差 Collections.sort(mlist, itemComparator); // LogUtils.E(mlist.size() + "sort後--"); }