-
-
Save iyengarajay/2eb92fc03b7d9ac5dd105bdf15e8df5d 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
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