Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Last active Jul 3, 2016
Embed
What would you like to do?
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