Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Created July 14, 2016 11:51
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/2eb92fc03b7d9ac5dd105bdf15e8df5d to your computer and use it in GitHub Desktop.
Save iyengarajay/2eb92fc03b7d9ac5dd105bdf15e8df5d to your computer and use it in GitHub Desktop.
List<String> strings = Arrays.asList("Joey", "Ben","Sandra","Glen");
Comparator<String> sortByLength = (String s1, String s2)-> s1.length() < s2.length() ? 1 : -1;
Collections.sort(strings, sortByLength);
System.out.println(strings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment