maxWithOrNull

fun <T> Array<out T>.maxWithOrNull(comparator: Comparator<in T>): T?(source)
fun IntArray.maxWithOrNull(comparator: Comparator<in Int>): Int?(source)
fun <T> Iterable<T>.maxWithOrNull(comparator: Comparator<in T>): T?(source)

Returns the first element having the largest value according to the provided comparator or null if there are no elements.

Since Kotlin

1.4

inline fun <K, V> Map<out K, V>.maxWithOrNull(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?(source)

Returns the first entry having the largest value according to the provided comparator or null if there are no entries.

Since Kotlin

1.4