2020
10-09
10-09
java list集合排序按某一属性排序操作
我就废话不多说了,大家还是直接看代码吧~publicList<FreightM>sortList(List<FreightM>list){Collections.sort(list,newComparator<FreightM>(){@Overridepublicintcompare(FreightMo1,FreightMo2){if(o1.getType()==0){return-1;}else{return1;}}});returnlist;}实现compareTo()方法,返回值为-1,第一个参数排前面;返回值为1...
继续阅读 >