Created
July 11, 2016 00:03
-
-
Save cbweixin/9d2cfa21d1992d800d794fa72a11121d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comparator<List<Integer>> cp = new Comparator<List<Integer>>(){ | |
public int compare(List<Integer> l1 , List<Integer> l2){ | |
return l1.size()-l2.size(); | |
} | |
} ; | |
Collections.sort(res,cp); | |
//With JDK 8 the syntax is much simpler. | |
List<CustomObject> list = new ArrayList<CustomObject>(); | |
Collections.sort(list, (left, right) -> left.getId() - right.getId()); | |
System.out.println(list); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment