There is a function in the API called maxElement that you can use very simply, which returns the maximum element in self or nil if the sequence is empty and requires strict weak ordering as closure in your case when you use a dictionary. You can use as in the following example:
var data : [Float:Float] = [0:0,1:1,2:1.414,3:2.732,4:2,5:5.236,6:3.469,7:2.693,8:5.828,9:3.201] let element = data.maxElement { $0.1 < $1.1} // (.0 8, .1 5.828)
And get the maximum value by value, but you can change how you want to use it by keys, it is up to you.
Hope this helps you.
Victor sigler
source share