上QQ阅读APP看书,第一时间看更新
Stream.sort()
We can sort a stream by calling the sort() function. Let's use the sort() function on the languages list, as shown in the following code:
languages.stream().sorted();
This will sort the elements in alphabetical order. We can provide a lambda expression to sort the elements using custom comparison logic.