Skip to content

Tag Archives: Java-Comparator

Given a linked list, the task is to sort the linked list using HeapSort. Examples: Input: list = 7 -> 698147078 -> 1123629290 -> 1849873707… Read More
Given a 2D array plates[][] of size N, which each row representing the length and width of a N rectangular plates, the task is to… Read More
The Vector class implements a growable array of objects. Vectors basically fall in legacy classes but now it is fully compatible with collections. It is… Read More
This error is thrown by TreeSet because TreeSet is used to store elements in sorted order and if the specified element cannot be compared with… Read More
The TreeMap in Java is used to implement Map interface and NavigableMap along with the AbstractMap Class. The map is sorted according to the natural… Read More
TreeSet is the implementation class of Set Interface. It follows a natural sorting order or you can customize it using a comparator and it also… Read More
A comparator is an interface that is used to rearrange the ArrayList in a sorted manner. A comparator is used to sort an ArrayList of… Read More
Given an array of strings arr[], consisting of N strings each representing dot separated numbers in the form of software versions. Input: arr[] = {“1.1.2”,… Read More
Given an array arr[] of IP Addresses where each element is a IPv4 Address, the task is to sort the given IP addresses in increasing… Read More
The comparingDouble(java.util.function.ToDoubleFunction) method of Comparator Interface in Java accepts a function as parameter that extracts an double sort key from a type T, and returns… Read More
The thenComparingDouble(java.util.function.ToDoubleFunction) method of Comparator Interface in Java returns a lexicographic-order comparator with a function that extracts a double sort key. This method is applied… Read More
The thenComparingLong(java.util.function.ToLongFunction) method of Comparator Interface in Java returns a lexicographic-order comparator with a function that extracts a Long sort key. Syntax: default Comparator <T>… Read More
The comparingLong(java.util.function.ToLongFunction) method of Comparator Interface in Java accepts a function as parameter that extracts an long sort key from a type T, and returns… Read More
The naturalOrder() method of Comparator Interface in Java returns a comparator that use to compare Comparable objects in natural order. The returned comparator by this… Read More
The reversed() method of Comparator Interface in Java returns a comparator that imposes the reverse ordering of this comparator. If you use sort method of… Read More