- Learn Selenium
- Unmesh Gundecha Carl Cocchiaro
- 49字
- 2021-06-24 13:25:38
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.