seq.grouped(by:)

// โญ๏ธ seq.grouped(by:)
extension Sequence {
    public func grouped<Key>(
        by keyForValue: (Element) -> Key
    ) -> [Key: [Element]] 
    {
        return Dictionary(grouping: self, by: keyForValue)
    }
}

Last updated