I\'m interested in sorting a list from a stream. This is the code I\'m using:
list.stream()
.sorted((o1, o2)->o1.getItem().getValue().compareTo(o2.get
This is a simple example :
List citiesName = Arrays.asList( "Delhi","Mumbai","Chennai","Banglore","Kolkata");
System.out.println("Cities : "+citiesName);
List 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