Top "Comparator" questions

A Common interface to create an object that specifies the way of comparing other objects.

Compare two Java Collections using Comparator instead of equals()

Problem Statement I have two Collections of the same type of object that I want to compare. In this case, …

java collections equals comparator
Help comparing float member variables using Comparators

I am able to compare Strings fine, but would like to know how I can rank floating point numbers? getChange() …

java sorting arraylist comparator comparable
null-safe mapping Comparator using default implementations

Is there a build-in possibility to create a null-safe mapping comparator in Java 8 without writing a own implementation of Comparator? …

java java-8 comparator
Using Comparable for multiple dynamic fields of VO in java

I have a class public class StudentVO { int age; String name; } I used the same class in two different areas. …

java comparator comparable
java TreeSet - don't remove duplicate items

TreeSet removes different items with the same Comprator value. I don't want it be removed. Is there any way to …

java comparator treeset
Comparable and Comparator contract with regards to null

Comparable contract specifies that e.compareTo(null) must throw NullPointerException. From the API: Note that null is not an instance …

java generics null comparator comparable
How come generic type parameter says "extends" Comparable not "implements"?

I tried to write generic function that remove the duplicate elements from array. public static <E extends Comparable<…

java generics comparator
Java stream sort 2 variables ascending/desending

I want to sort seq1 ascending and seq2 descending so I do this: list = list.stream().sorted(comparing(AClass::getSeq1).…

java sorting java-8 comparator java-stream
Why Comparator.comparing doesn't work with String::toLowerCase method reference?

I am trying to sort an array of Strings by reverse order (ignoring case), without modifying it, and just printing …

java comparator java-8 java-stream method-reference
Jasper Reports crosstab sorting with comparatorExpression

I'm trying to sort my dynamic columns in a cross tab according to some custom scheme. In the docs I …

sorting jasper-reports comparator crosstab