diff --git a/runtime/src/main/kotlin/kotlin/comparisons/Comparisons.kt b/runtime/src/main/kotlin/kotlin/comparisons/Comparisons.kt index d0144d9e2ec..ca60cf17cbc 100644 --- a/runtime/src/main/kotlin/kotlin/comparisons/Comparisons.kt +++ b/runtime/src/main/kotlin/kotlin/comparisons/Comparisons.kt @@ -4,6 +4,11 @@ interface Comparator { fun compare(a: T, b: T): Int } +fun Comparator(function: (a: T, b: T) -> Int): Comparator { + return object: Comparator { + override fun compare(a: T, b: T) = function(a, b) + } +} /** * Compares two values using the specified functions [selectors] to calculate the result of the comparison. * The functions are called sequentially, receive the given values [a] and [b] and return [Comparable]