2019-11-16a few seconds read (About 48 words)How to group array by property in SwiftIssue #510 Use Dictionary(grouping:by:) 12345678910func groups(countries: [Country]) -> [Group] { let dictionary = Dictionary(grouping: countries, by: { String($0.name.prefix(1)) }) let groups = dictionary .map({ (key: String, value: [Country]) -> Group in return Group(initial: key, countries: value) }) .sorted(by: { $0.initial < $1.initial }) return groups}#swift