Solved

How to use sort method of TList

Posted on 2001-08-14
1
160 Views
Last Modified: 2010-04-06
Hi,
I declared the following type :
type
  TSeg = Record
             Starts, Ends: integer;
           Type1, type2: tring;
         end;

var  PSeg : ^TSeg;
     slSeg : TList;  
I add PSeg into a slSeg. How can I sort the data in the slSeg depending on Starts or Ends?

PeterShaw
0
Comment
Question by:petershaw8
1 Comment
 
LVL 4

Accepted Solution

by:
fva earned 50 total points
ID: 6383698
Example sort by Starts:

function MyStartsCompare(Item1,Item2:Pointer):integer;
begin
     if PSeg(Item1)^.Starts=PSeg(Item2)^.Starts then Result:=0
     else if PSeg(Item1)^.Starts<PSeg(Item2)^.Starts then Result:=-1
     else Result:=1;
end;

procedure DoSortOnStarts;
begin
     slSeg.Sort(MyStartsCompare);
end;

For Ends you'll figure it out :)

F.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
indy tidtcpclient threading issue 8 54
PDF library for Delphi 2 89
Communication Between RC4 Delphi <-> PHP 3 86
LAN or WAN ? 11 61
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now