TList的Sort使用方法
来源:互联网 发布:网络综合布线施工合同 编辑:程序博客网 时间:2024/06/10 18:25
有网友提问,做一Demo,以作记录。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Math;
type
P_MissInfo = ^MissInfo;
MissInfo = record
Missqty: integer;
MissRate: Double;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function CompareNames(Item1, Item2: Pointer): Integer;
begin
result := Integer(CompareValue(P_MissInfo(Item1).MissRate, P_MissInfo(Item2).MissRate));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
list: Tlist;
PMissInfo: P_MissInfo;
begin
list := Tlist.create;
New(PMissInfo);
PMissInfo.Missqty:= 10;
PMissInfo.MissRate:= 12.56;
list.Add(PMissInfo);
New(PMissInfo);
PMissInfo.Missqty:= 12;
PMissInfo.MissRate:= 12.8;
list.Add(PMissInfo);
New(PMissInfo);
PMissInfo.Missqty:= 9;
PMissInfo.MissRate:= 11.56;
list.Add(PMissInfo);
list.Sort(@CompareNames);
Showmessage(IntToStr(list.Count));
showmessage(FloatToStr(P_MissInfo(list.Items[0]).MissRate));
showmessage(FloatToStr(P_MissInfo(list.Items[1]).MissRate));
showmessage(FloatToStr(P_MissInfo(list.Items[2]).MissRate));
end;
end.
- TList的Sort使用方法
- TList的Sort使用方法
- 关于TLIST排序SORT的使用
- BCB的TList
- TList的用法
- Tlist
- Tlist
- tlist -
- Tlist
- TList
- java中sort的使用方法
- Linux命令:sort的使用方法
- 【sort函数】的基本使用方法
- ctags、vim、Tlist的使用
- ctags、vim、Tlist的使用
- linux命令Tlist的安装
- Vim的Ctags+Tlist+Cscope
- delphi中Tlist的使用。
- 归因理论
- iiOS开发UI篇--IOS动画(Core Animation)总结
- 畅通工程续 1874(模板)
- Atom编辑器折腾记_(13)JS代码智能提示补全(插件:atom-ternjs)
- Linux进程间通信——使用匿名管道
- TList的Sort使用方法
- 浅谈成为高级程序员的 10 个步骤
- MySQL MongoDB 常用命令对比
- ORACLE数据库定时任务
- 从零搭建 repo 服务器
- VC++ 创建Windows服务
- hdu5384 Danganronpa(ac自动机+处理源字符串总容量超过二维数组容量的技巧(连接+分割))
- Introduction to Face Detection and Face Recognition
- bootstrap的datepicker控件使用心得