class Solution {
fun numberOfWeakCharacters(properties: Array<IntArray>): Int {
properties.sortWith(compareBy( { -it[0]}, { it[1] }))
var weak = 0
var maxDefense = 0
for (property in properties) {
if (maxDefense > property[1]) weak++
maxDefense = maxOf(maxDefense, property[1])
}
return weak
}
}