请问:如何将List中的多个对象排序? TList类中有一个Sort方法,但我不知道怎么用,请高手指教!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 type PRecord = ^TMyRec; TMyRec = record s: string[8]; i: integer; d: double;end;function CompareInt(Item1, Item2: PRecord): Integer; //排序begin Result := CompareValue(Item1.i, Item2.i);end;procedure TForm1.Button1Click(Sender: TObject);var MyList: TList; PR: PRecord;begin MyList := TList.Create; try New(PR); PR.s := '10000001'; PR.i := 1001; PR.d := 0.1; MyList.Add(PR); {...} MyList.Sort(@CompareInt); //Integer類Sort finally MyList.Free; end;end;注:你的问题太笼统,不知你的TList类中装的内容是什麽 在此给你一个装记录指针,对其中一项排序. delphi过滤htm的问题 case 如何表示大于或小于 其他编程语言能否使用Borland Socket Server? 怎样安装下载的控件?? 怎样判断Image里面有没有图片? 帮忙看看出了什么问题,(update语句的语法错误) 关于jpeg图像的问题,请帮忙! 怎么样用delphi运行一个注册命令? 请以前做过pic to exe的大虾指教 一个自定义控件的简单问题 Delphi的第三方控件 如何将(多字段主键)数据插入到另一表中,表结构相同 (100分,解决立刻给分!)
PRecord = ^TMyRec;
TMyRec = record
s: string[8];
i: integer;
d: double;
end;function CompareInt(Item1, Item2: PRecord): Integer; //排序
begin
Result := CompareValue(Item1.i, Item2.i);
end;procedure TForm1.Button1Click(Sender: TObject);
var MyList: TList;
PR: PRecord;
begin
MyList := TList.Create;
try
New(PR);
PR.s := '10000001';
PR.i := 1001;
PR.d := 0.1;
MyList.Add(PR);
{...}
MyList.Sort(@CompareInt); //Integer類Sort
finally
MyList.Free;
end;
end;注:你的问题太笼统,不知你的TList类中装的内容是什麽
在此给你一个装记录指针,对其中一项排序.