Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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