-
-
Save iyengarajay/1513c2109d95107284a2315f3bc1055f 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"); | |
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