Solved

How to use sort method of TList

Posted on 2001-08-14
1
168 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

719 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