Java natural sort (Comparable) with lambda
In this example, we can see the class Person and we use stream’s sorted() method to sort the list of people by their age. So in order for sorted() to work, it needs to have a natural order. For this reason, we have to implement the Comparable interface for the class which needs to be … Read more