sortByCount

fun <T, G> GroupBy<T, G>.sortByCount(): GroupBy<T, G>

Sorts the key-group pairs of this GroupBy by the number of rows in groups descending.

Returns a new GroupBy containing the same keys and groups in the resulting order. The contents of the groups remain unchanged.

Don't confuse this with sortBy that sorts rows within groups.

See also

Check out GroupBy grammar.

For more information: See "GroupBy Transformation" on the documentation website.

Return

A new GroupBy with its key-group pairs sorted by the group sizes.