compareValuesBy

fun <T> compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int(source)

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 objects. As soon as the Comparable instances returned by a function for a and b values do not compare as equal, the result of that comparison is returned.

Since Kotlin

1.0

Samples


inline fun <T> compareValuesBy(a: T, b: T, selector: (T) -> Comparable<*>?): Int(source)

Compares two values using the specified selector function to calculate the result of the comparison. The function is applied to the given values a and b and return Comparable objects. The result of comparison of these Comparable instances is returned.

Since Kotlin

1.0

Samples


inline fun <T, K> compareValuesBy(a: T, b: T, comparator: Comparator<in K>, selector: (T) -> K): Int(source)

Compares two values using the specified selector function to calculate the result of the comparison. The function is applied to the given values a and b and return objects of type K which are then being compared with the given comparator.

Since Kotlin

1.0

Samples