Companion

Companion object for Comparator interface providing factory methods for creating Comparator instances.

Functions

Link copied to clipboard
context(order: Order<Element>)
fun <Target, Element> Comparator.Companion.byOrdered(vararg selectors: (Target) -> Element): Comparator<Target>

Creates a comparator using the sequence of functions to calculate a result of comparison. The functions are called sequentially, receive the given values a and b and return objects comparable via Order context receiver. As soon as the instances returned by a function for a and b values do not compare as equal, the result of that comparison is returned from the Comparator. Otherwise 0 is returned.

Link copied to clipboard

Returns Comparator instance which Comparator.compare operator just uses Comparable.compareTo operator's result as a return value.