List sort 排序
正序:
1 resultList.sort((o1, o2) -> { 2 //正序 3 double diff = o1.getNum() - o2.getNum(); 4 if (diff > 0) { 5 return 1; 6 }else if (diff < 0) { 7 return -1; 8 } 9 return 0; 10 });
倒序:
resultList.sort((o1, o2) -> { //倒序 double diff = o2.getNum() - o1.getNum(); if (diff > 0) { return 1; }else if (diff < 0) { return -1; } return 0; });