Top "Comparator" questions

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

Sorting ArrayList of Arraylist<String> in java

I have an ArrayList of ArrayList of String. In Outer ArrayList on each index each Inner ArrayList has four items …

java sorting arraylist comparator comparable
Sorting using Comparator Interface and java 8 Streams

Parent is a class which is inherited by Child. which is inherited by GrandChild. Each class contains List of the …

java sorting java-8 comparator java-stream
How does Javascript's sort() work?

How does the following code sort this array to be in numerical order? var array=[25, 8, 7, 41] array.sort(function(a,b){ …

javascript sorting comparator
Java 8 Comparator nullsFirst naturalOrder confused

this may be a simple question but I would like to understand it clearly... I have a code like this: …

java string sorting java-8 comparator
Does a natural comparator exist in the standard api?

I need a comparator as part of a strategy pattern that can either use the natural ordering of the objects …

java comparator comparable
Very confused by Java 8 Comparator type inference

I've been looking at the difference between Collections.sort and list.sort, specifically regarding using the Comparator static methods and …

java sorting lambda java-8 comparator
Comparator for min-heap in C++

I am trying to make a min-heap1 of longs in C++ using the STL make_heap, etc., but my comparator …

c++ stl heap comparator min-heap
why does my compare method throw exception -- Comparison method violates its general contract!

Why does this code public class SponsoredComparator implements Comparator<SRE> { public boolean equals(SRE arg0, SRE arg1){ return …

java android comparator contract
Comparator.reversed() does not compile using lambda

I have a list with some User objects and i'm trying to sort the list, but only works using method …

java lambda java-8 comparator method-reference
How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), …

java sorting enums comparator alphabetical