2,498
社区成员
发帖
与我相关
我的任务
分享
unit customSort;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function asort(List:TstringList;index1,index2:integer):integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var stringList:TstringList;
begin
stringList:=TstringList.Create;
stringList.Add('我');
stringList.Add('你');
stringList.Add('他');
stringList.Add('她');
stringList.CustomSort(asort);
showmessage(stringList[0]+';'+stringList[1]+';'+stringList[2]+';'+stringList[3]+';');
end;
function asort(list:TstringList;index1,index2:integer):integer;
begin
Result := Random(3-1+1);
end;
end.
Delphi2010下测试通过