Java Collections.sort 用法
2015-07-16 18:04
411 查看
Collections.sort(list, new Comparator<ActivitiesBanksDTO>() { @Override public int compare(ActivitiesBanksDTO o1, ActivitiesBanksDTO o2) { Integer diff = o1.getDisplayTemplateId() - o2.getDisplayTemplateId(); if (diff > 0) // return -1; else if (diff == 0) { Integer launch = o1.getLaunchId() - o2.getLaunchId(); if (launch > 0) { return -1; } else if (launch == 0) { return 0; } else { return 1; } } else return 1; } });
这个是排序方法
先根据
getDisplayTemplateId() 排序 如果<pre name="code" class="cpp">getDisplayTemplateId()相同 再根据 <pre name="code" class="cpp">getLaunchId()排序
相关文章推荐
- Java中Json字符串直接转换为对象(包括多层List集合)
- java中的char,short,int,long占几个字节
- 【OSGi】Could not find bundle: org.eclipse.equinox.console
- 关于魅族手机无法链接到eclipse
- Spring contextConfigLocation和ContextLoaderListener理解。
- java 解析 html 的利器-->jsoup
- HDFS的java接口——简化HDFS文件系统操作
- eclipse里,android项目下如何attach source
- argument.callee
- Thinking in java 读书笔记
- JAVA面试题:Spring中bean的生命周期
- Spring AOP声明式事务异常回滚
- spring中@Component注解
- spring aop中的propagation的7种配置的意思
- 关于spring-servlet.xml cannot be opened because it does not exist的解决
- 通配符的匹配很全面, 但无法找到元素 'context:component-scan'
- 用报表软件自定义地图
- Spring中的AOP
- Java 并发:Executor ExecutorService ThreadPoolExecutor
- 在 Java EE 组件中使用 Camel Routes