面试题答案
一键面试data class Person(val name: String, val age: Int)
fun main() {
val personList = listOf(
Person("Alice", 30),
Person("Bob", 25),
Person("Charlie", 28),
Person("David", 22),
Person("Eve", 27)
)
val sortedList = personList.sortedWith(compareBy<Person> { it.name.length }.thenBy { it.age })
sortedList.forEach { println(it) }
}