Top "Comparator" questions

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

Java Map sort by value

I was looking for ways of sorting Map<String, Integer> by values. I found this post, which solved …

java sorting hashmap comparator treemap
Inline comparator vs custom comparator in Java

When sorting a list, is there any performance difference between using a java Comparator in-line (with an anonymous inner class) …

java performance comparator
Comparator and equals()

Suppose I need TreeSet with elements sorted with some domain logic. By this logic it doesn't matter order of some …

java equals comparator treeset
Implement Comparator for primitive boolean type?

I need some classes implements Comparator, and for one I want to compare primitive boolean (not Boolean) values. IF it …

java comparator primitive-types
Comparator.comparing(...) of a nested field

Suppose I have a domain model like this: class Lecture { Course course; ... // getters } class Course { Teacher teacher; int studentSize; ... // getters } …

java lambda java-8 comparator
How to pass a custom comparator to "sort"?

Class A has the following comparator: class A attr_accessor x def my_comparator(a) x**2 <=> (a.x)**2 …

ruby sorting comparator
How get List from Set and Comparator

What is the "good" (and why ?) solution to get a List from a Set and sorted against a given Comparator ?

java list set comparator
compare object properties and show diff in PHP

I'm searching for a way to show me the different properties/values from given objects... $obj1 = new StdClass; $obj1-&…

php object diff comparator
Why should a Comparator implement Serializable?

New to Java. Learning it while working on an Android app. I am implementing a Comparator to sort a list …

java android sorting serialization comparator
Kotlin object expressions: Comparator example

This code basically sorts the array in a descending order: val arrayList = arrayListOf(1, 5, 2) Collections.sort(arrayList, object : Comparator<Int&…

java comparator anonymous-class kotlin