java 自定义排序

//main中Collections.sort(totalList,new MyComparator());
 class MyComparator implements Comparator<MerAndMon> {

				@Override
				public int compare(MerAndMon m1, MerAndMon m2) {
					if(m1.getMerId().compareTo(m2.getMerId()) == 1){
						return  1 ;
					}else if(m1.getMerId().compareTo(m2.getMerId()) == -1){
						return -1 ;
					}else{
						return 0 ;
					}
				}
		 }

 

 

你可能感兴趣的:(java 自定义排序)