Equivalent Delphi code for your Cocoa code:
type
TScorePair = TPair<string,Integer>;
var
ScoresArray: TArray<TScorePair>;
....
ScoresArray := Scores.ToArray;
TArray.Sort(ScoresArray,
TComparer<TScorePair>.Construct(
function(const L, R: TScorePair): Integer
begin
Result := R.Value - L.Value;
end
)
);
If your dictionary is very large, this will not be the most effective solution. On the other hand, this is probably the fastest and easiest implementation approach.
source
share