Skip to content

Instantly share code, notes, and snippets.

@cbweixin
Created July 11, 2016 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbweixin/9d2cfa21d1992d800d794fa72a11121d to your computer and use it in GitHub Desktop.
Save cbweixin/9d2cfa21d1992d800d794fa72a11121d to your computer and use it in GitHub Desktop.
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