Solved

How to use sort method of TList

Posted on 2001-08-14
1
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

726 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