Sorting a collection using Lambda comparator

This is NOT the official website
of Java.
class Person {
    public String name;
    public int age;
}
 
List<Person> persons = new ArrayList<>(); // TODO we should add some persons to this list
 
 
// Sorting the persons by name is easy: using lambda to implement the Comparator
Collections.sort(persons, (p1, p2) -> p1.name.compareTo(p2.name));
 
 
// Before Java 8, we had to write code like this:
Collections.sort(persons, new Comparator<Person>() {
    public int compare(Person p1, Person p2) {
        return p1.name.compareTo(p2.name);
    }
});