作者:david_zhang@sh 【转载时请以超链接形式标明文章】
http://www.cnblogs.com/david-zhang-index/p/4246887.html
当某个List<T>未实现Comparable<T>但又需要根据某个字段排序
1,降序,从大到小
1 Collections.sort(ListName,(obj1,obj2)->{ 2 if(obj1.getPrice()<obj2.getPrice()) 3 return 1; 4 else 5 return -1; 6 });
2,升序,从小到大
1 Collections.sort(ListName,(obj1,obj2)->{ 2 if(obj1.getPrice()<obj2.getPrice()) 3 return 1; 4 else 5 return -1; 6 });
标签:sort,obj1,obj2,zhang,Collections,工具,getPrice From: https://www.cnblogs.com/david-zhang-index/p/16835781.html