Collections.sort with lambda expressions

The sort(List<T> list, Comparator<? super T> c) method of the Collections class enables to use lambda expressions in sorting as Interface Comparator <T> is a functional interface and can be used with lambda expressions.


Collections.sort(studentList, Comparator.comparing(Student::getCgpa).reversed().thenComparing(Student::getFname).thenComparing(Student::getId) );

for(Student st: studentList){
System.out.println(st.getFname());
      }
      

This code was used at this challenge.