Вы можете сделать это так:
let dict1: [String:Any] = ["type":"steps","value": 100]
let dict2: [String:Any] = ["type":"cal","value": 200]
let dict3: [String:Any] = ["type":"cal","value": 300]
let dict4 : [String:Any] = ["type":"steps","value": 400]
let dict5 : [String:Any] = ["type":"cal","value": 500]
let array = [dict1,dict2,dict3,dict4,dict5]
let list :[String:[[String:Any]]] = Dictionary(grouping: array, by: {$0["type"] as? String ?? ""})
let result = list.map { (key,value) -> [String:Any] in
let sum = value.reduce(0, {$0 + ($1["value"] as? Int ?? 0)})
return ["type":key , "value":sum]
}
print(result)
OutPut:
[["type": "cal", "value": 1000], ["type": "steps", "value": 500]]