# Effective Kotlin Item 56: Consider using groupingBy instead of groupBy

DevFeed: [Effective Kotlin Item 56: Consider using groupingBy instead of groupBy](<https://devfeed.tech/articles/effective-kotlin-item-56-consider-using-groupingby-instead-of-groupby-39280.md>)

Original publisher: [Read original article](<https://kt.academy/article/ek-grouping>)

Published: 2021-10-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [groupby](<https://devfeed.tech/topics/groupby.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [performance-optimization](<https://devfeed.tech/topics/performance-optimization.md>), [Collections](<https://devfeed.tech/topics/collections.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [collections](<https://devfeed.tech/tags/collections.md>), [groupby](<https://devfeed.tech/tags/groupby.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

## AI overview

This tutorial explains how Kotlin's groupBy and groupingBy functions organize elements from an iterable by key. It describes groupBy as the simpler option that creates collections for each key, while groupingBy can reduce work and memory use in performance-critical code by processing groups through operations such as counting and aggregation.

## Source excerpt

What Grouping is, and how groupingBy instead of groupBy can be a performance optimization.