利用apache Collections和google guava对list和map进行过滤和排序

http://www.jiancool.com/article/50723356810/
在工作中,我们常常需要对List或者Map等集合结果过滤或者排序,这里我通过使用apache commons和google guava中的方法,简单实现了一下,方便以后使用。
例子中使用的是apache commons3.1和google-guava14,最新版本是18
apache项目下载地址:http://projects.apache.org/indexes/quick.html
apache Collectoins下载地址:http://commons.apache.org/proper/commons-collections/

    apache代码如下:

对List中的对象按不同属性排序,请看此

打印结果:

Twitter,3

Youtube,4

Telerik,5

Google,6

Google,6

——————-你懂的————————

Apple,1

Facebook,2

Twitter,3

Youtube,4

Telerik,5

Google,6

      google guava代码:

打印结果:

Map-UserGuava=Telerik,3

Map-UserGuava=Twitter,5

Map-UserGuava=Google,4

——————-你懂的————————

List-UserGuava=Telerik,3

List-UserGuava=Google,4

List-UserGuava=Twitter,5

——————-你懂的————————

List-IN-UserGuava=Telerik,3

List-IN-UserGuava=Google,4

List-IN-UserGuava=Twitter,5

——————-你懂的————————

List-Sort-UserGuava=JetBrains,1

List-Sort-UserGuava=Youtube,1

List-Sort-UserGuava=Apple,2

List-Sort-UserGuava=Facebook,2

List-Sort-UserGuava=Telerik,3

List-Sort-UserGuava=Google,4

List-Sort-UserGuava=Twitter,5