Skip to content

Instantly share code, notes, and snippets.

@hudsonmendes
Created November 13, 2018 11:34
Show Gist options
  • Save hudsonmendes/a1baf3dec494fba3819ea1691bd6208c to your computer and use it in GitHub Desktop.
Save hudsonmendes/a1baf3dec494fba3819ea1691bd6208c to your computer and use it in GitHub Desktop.
Sort using Comparator.comparing
public class OrderingServiceImpl implements OrderingService {
@Override
public List<SearchResult> orderWithComparator(List<SearchResult>) {
return results
.stream()
.distinct()
.sorted(Comparator.comparing(SearchResult::getName))
.collect(toList());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment