Skip to content

Instantly share code, notes, and snippets.

@keinix
Last active April 26, 2018 12:15
Show Gist options
  • Save keinix/911cdc48755ec700dfe87d4b260dbf32 to your computer and use it in GitHub Desktop.
Save keinix/911cdc48755ec700dfe87d4b260dbf32 to your computer and use it in GitHub Desktop.
Sort an object based on a String field
public void sortSubReddits(List<SubReddit> subreddits) {
Collections.sort(subreddits, (sub1, sub2) ->
String.CASE_INSENSITIVE_ORDER.compare(sub1.getDisplayName(), sub2.getDisplayName()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment