+ 1

How get max value of Dictionary in swift?

key of Dictionary is string and value is Int.

19th Jul 2018, 6:52 PM
Gurvindra
Gurvindra - avatar
1 Answer
+ 1
let dic = ["a": 5, "b": 7, "c": 9] var arr = [Int]() for i in dic.values { arr.append(i) } arr = arr.sorted(){$0 > $1} print("Max value:\(arr[0])")
28th Jul 2018, 4:17 PM
Kevin