SL.CustomSort(CompareFloat);
works if you add {$mode delphi}
directive to somewhere to the beginning of a unit.
However SL.CustomSort(@CompareFloat);
should work fine. Make sure the error message is not caused by something else.
Example:
program Project1;
//{$mode delphi}
uses
Classes,
SysUtils;
function CompareFloat(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := StrToInt(List[Index1]) - StrToInt(List[Index2]);
end;
var
SL: TStringList;
begin
SL := TStringList.Create;
try
SL.Add('3');
SL.Add('2');
SL.Add('1');
SL.CustomSort(@CompareFloat);
//SL.CustomSort(CompareFloat);
Writeln(SL[0], SL[1], SL[2]);
Readln;
finally
SL.Free;
end;
end.