val names = arrayOf("Alice", "Bob", "Charlie") // 按名字长度对数组进行排序 names.sortWith { n1, n2 -> n1.count() - n2.count() } // 按名字长度对数组进行排序: [Bob, Alice, Charlie] names.forEach { _console.log(it) }