Reputation: 8043
I need to sort a TArray<integer>
, I've added System.Generics.Collections
to the uses
clause and then I've tried the following code:
var
Arr : TArray<integer>;
begin
SetLength(Arr, 2);
Arr[0] := 5;
Arr[1] := 3;
TArray.Sort(Arr);
ShowMessage(IntToStr(Arr[0]));
end;
On compiling it produces an E2250 error saying:
[dcc32 Error] Unit1.pas(39): E2250 There is no overloaded version of 'Sort' that can be called with these arguments
Upvotes: 1
Views: 1120
Reputation: 8043
While writing the question I've found the answer... (It was a trivial syntax problem)
In TArray
class, the Sort
function is defined as follows:
class procedure Sort<T>(var Values: array of T); overload; static;
So TArray
class functions must be called by specifying the type after the function name:
var
Arr : TArray<integer>;
begin
SetLength(Arr, 2);
Arr[0] := 5;
Arr[1] := 3;
TArray.Sort<integer>(Arr);
ShowMessage(IntToStr(Arr[0]));
end;
Upvotes: 3