unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Compare_i(List: TStringList;
Index1, Index2: Integer): Integer;
var
v1, v2: integer;
begin
v1 := integer(List.Objects[Index1]);
v2 := integer(List.Objects[Index2]);
Result := v1 - v2;
if Result = 0 then
Result := Index1 - Index2;
end;
procedure sort_int(var list: array of integer);
var
sl: TstringList;
i, idx: Integer;
begin
sl := TstringList.Create;
for i := low(list) to high(list) do
sl.AddObject('', TObject(list));
sl.CustomSort(Compare_i);
idx := 0;
for i := low(list) to high(list) do
begin
list := integer(sl.Objects[idx]);
inc(idx);
end;
FreeAndNil(sl);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
list: array of integer;
i: integer;
begin
Randomize;
setlength(list, 10000);
for i := low(list) to high(list) do
list := Random(1000);
sort_int(list);
setlength(list, 0);
end;
end.