Created
November 13, 2018 11:34
-
-
Save hudsonmendes/a1baf3dec494fba3819ea1691bd6208c to your computer and use it in GitHub Desktop.
Sort using Comparator.comparing
This file contains hidden or 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
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