主题:帮帮我啊,下面代码如何才能实现tlist.sort排序?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type
pmuo=^muo;
muo = record
muoname:string;
hsgs:integer;
end;
var
muoList: TList;
amuo:pmuo;
begin
muolist:=TList.Create;
New(amuo);
amuo.muoname:='d:\001.bmp';
amuo.hsgs:=3;
muolist.Add(amuo);
New(amuo);
amuo.muoname:='d:\002.bmp';
amuo.hsgs:=2;
muolist.Add(amuo);
end;
end.
现在想根据muolist各项的 的hsgs字段进行排序,我只知首muolist.sort() 可以实现,可是搞了半天还是一头雾水,请大侠们帮一下我啊,最好能写一点儿代码,万分感谢!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type
pmuo=^muo;
muo = record
muoname:string;
hsgs:integer;
end;
var
muoList: TList;
amuo:pmuo;
begin
muolist:=TList.Create;
New(amuo);
amuo.muoname:='d:\001.bmp';
amuo.hsgs:=3;
muolist.Add(amuo);
New(amuo);
amuo.muoname:='d:\002.bmp';
amuo.hsgs:=2;
muolist.Add(amuo);
end;
end.
现在想根据muolist各项的 的hsgs字段进行排序,我只知首muolist.sort() 可以实现,可是搞了半天还是一头雾水,请大侠们帮一下我啊,最好能写一点儿代码,万分感谢!