Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Last active July 3, 2016 11:57
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 iyengarajay/1513c2109d95107284a2315f3bc1055f to your computer and use it in GitHub Desktop.
Save iyengarajay/1513c2109d95107284a2315f3bc1055f to your computer and use it in GitHub Desktop.
List<String> strings = Arrays.asList("Joey", "Ben","Sandra","Glen");
Collections.sort(strings, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.length() < s2.length() ? 1 : -1;
}
});
System.out.println(strings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment