用Collections升降排序

//期末从业人员 总收入 资产总计等 升降 排序
		if("qmcyry".equals(sss)){
			if("desc".equals(orders)){
				Collections.sort(sjsReportDistributionPageList, new Comparator<SjsReportDistributionPage>() {
					@Override
					public int compare(SjsReportDistributionPage user1, SjsReportDistributionPage user2) {
						int zsr1 = Integer.parseInt(user1.getQmcyry());
						int zsr2 = Integer.parseInt((user2.getQmcyry()));
						return zsr1>zsr2?-1:1;
					}
				});
			}else if("asc".equals(orders)){
				Collections.sort(sjsReportDistributionPageList, new Comparator<SjsReportDistributionPage>() {
					@Override
					public int compare(SjsReportDistributionPage user1, SjsReportDistributionPage user2) {
						int zsr1 = Integer.parseInt(user1.getQmcyry());
						int zsr2 = Integer.parseInt((user2.getQmcyry()));
						return zsr1>zsr2?1:-1;
					}
				});
			}
		}

  项目中用到的,获取排序字段,用底层算法比对排序。

posted @ 2017-02-07 14:28  caozengling  阅读(303)  评论(0编辑  收藏  举报