grouped(by:)

Groups up elements of self into a new Dictionary, whose values are Arrays of grouped elements, each keyed by the group key returned by the given closure.

Grouped.swift:22
func grouped<GroupKey>(by keyForValue: (Element) throws -> GroupKey) rethrows -> [GroupKey : [Element]] where GroupKey : Hashable

Parameters

keyForValue

A closure that returns a key for each element in self.

Returns

A dictionary containing grouped elements of self, keyed by the keys derived by the keyForValue closure.