Skip to content

Instantly share code, notes, and snippets.

@xrrocha
Created March 5, 2018 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xrrocha/2436610b65ee459f0feedb7817d84df1 to your computer and use it in GitHub Desktop.
Save xrrocha/2436610b65ee459f0feedb7817d84df1 to your computer and use it in GitHub Desktop.
private List<String> pack(Stream<String> editResults) {
return editResults
// Remove duplicates
.distinct()
// Select only words present in dictionary
.filter(dictionary::containsKey)
// Sort by word rank so more frequent words show first
.sorted(Comparator.comparing(dictionary::get))
.collect(toList());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment