2026/11/5 -Sort a list in Java with List.sort(), Collections.sort(), and Stream.sorted() – in descending order, by several fields, and with accents.
2026/10/10 -To sort, Java compares two elements at a time and decides which one comes first. Java gets the answer from one of two interfaces.
2026/10/21 -Practice 25 Java lambda and functional interface exercises covering Predicate, Function, Supplier, Consumer, streams, and method references with solutions.
2026/9/22 -Collections.sort(names, new Comparator<String>() { @Override public int compare(String a, String b) { return a. ... length() - b. ... length(); } });.
2026/11/9 -Definition and Usage. The sort() method sorts the items of a list in ascending order. Strings are sorted alphabetically, and numbers are sorted numerically.
2026/8/27 -sort() method in Java is used to arrange array elements in ascending order. It works with different data types like integers, characters, strings, and more, ...
2026/11/6 -The lambda looks like: (p1, p2) -> { int diff = p2.score - p1.score; if (diff != 0) return diff; return p1.name.compareTo(p2.name); } . Notice that p2.score - ...
2026/10/17 -The Comparator interface in Java defines a sort order outside the class being sorted, through one method, compare(a, b), which returns a negative number, zero ...
2026/11/5 -Sort an array in Java: Arrays.sort() for primitives and objects, in descending order and in parallel – and which algorithms the JDK uses.
2026/9/4 -Learn how to sort a Map by its values in Java using Comparator, Stream API, lambda expressions, and more, with practical examples.