Data update
This commit is contained in:
parent
796d366b97
commit
35bcdeebf8
504 changed files with 7045 additions and 610 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public final class SortUsingCustomComparator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = List.of( "Here", "are", "some", "sample", "strings", "to", "be", "sorted" );
|
||||
|
||||
Comparator<String> custom = Comparator.comparing(String::length, Comparator.reverseOrder())
|
||||
.thenComparing(Comparator.naturalOrder());
|
||||
|
||||
List<String> sortedList = list.stream().sorted(custom).toList();
|
||||
|
||||
System.out.println(sortedList);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue