Kotlin

Grouping

Swift
                  val numbers = listOf("one", "two", "three", "four", "five")
​
println(numbers.groupBy { it.first().toUpperCase() })
println(numbers.groupBy(keySelector = { it.first() }, valueTransform = { it.toUpperCase() }))
                
                    let numbers = listOf("one", "two", "three", "four", "five")
​
print(numbers.groupBy { it.first().toUpperCase() })
print(numbers.groupBy(keySelector = { it.first() }, valueTransform = { it.toUpperCase() }))
                  
                  val numbers = listOf("one", "two", "three", "four", "five", "six")
println(numbers.groupingBy { it.first() }.eachCount())
                
                    let numbers = listOf("one", "two", "three", "four", "five", "six")
print(numbers.groupingBy { it.first() }.eachCount())