sortByKey

fun <T, G> GroupBy<T, G>.sortByKey(nullsLast: Boolean = false): GroupBy<T, G>

Sorts the key-group pairs of this GroupBy by the keys ascending.

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 keys.

Parameters

nullsLast

Whether null values are considered as the largest values when sorting. Default is false.