title: Which is best way to Find the max value in a delphi TDictionary?
body: <p>i have a TDictionary declared like so <code>TDictionary&lt;String,Integer&gt;</code>, Now i want to get the max of the value stored in the TDictionary. i can do this iterating over the <code>TDictionary</code> and comparing the values, but I'm wondering exist a better way to do this? <code>exist any function or maybe the dictionary can be sorted by the values to retrieve the max value stored?
  </code></p>
  
  <p>this is which i'am doing now</p>
  
  <pre><code>var
     MyDict       : TDictionary&lt;String,Integer&gt;;
     MaxValue, i  : Integer;
  begin
     MyDict:=TDictionary&lt;String,Integer&gt;.Create;
     try    
       MyDict.Add('this',1);
       MyDict.Add('is',7);
       MyDict.Add('a',899);
       MyDict.Add('sample',1000);
       MyDict.Add('finding',12);
       MyDict.Add('the',94);
       MyDict.Add('max',569);
       MyDict.Add('value',991);
  
       MaxValue:=MyDict.ToArray[0].Value;
       for i in MyDict.Values do
        if i&gt;MaxValue then MaxValue:=i;
  
       ShowMessage(Format('The max value is %d',[MaxValue]));
     finally
       MyDict.Free;
     end;
  end;
  </code></pre>