This is a simple example :
List<String> citiesName = Arrays.asList( "Delhi","Mumbai","Chennai","Banglore","Kolkata");
System.out.println("Cities : "+citiesName);
List<String> sortedByName = citiesName.stream()
.sorted((s1,s2)->s2.compareTo(s1))
.collect(Collectors.toList());
System.out.println("Sorted by Name : "+ sortedByName);
It may be possible that your IDE is not getting the jdk 1.8 or upper version to compile the code.
Set the Java version 1.8 for Your_Project > properties > Project Facets > Java version 1.8