Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 11th, 2005, 11:58 PM
Mainlander
Guest
 
Posts: n/a
Default TList.Sort


I have a class that I designed that contains some objects in its fields,
that are derived from the TList class.

I want to use the TList Sort procedure to sort the items that are in the
derived class. The derived class has an extra field that specifies how to
sort the items.

The problem I have is in the implementation of the Sort method in the way
the class is implemented by Borland. The call to the Sort method must
pass in the name of a simple procedure. The procedure call then receives
the pointers to the two items that it must return the order of.

Why oh why could Borland have not implemented the sort procedure call as
an event procedure or allow a method of another object to be passed as
the parameter to the Sort call, because I want the sort procedure to be
able to read the extra field in my class so that it knows how to carry
out the sort.

As the sort procedure does not receive any information about the calling
object there are various un-OO fudges like global variables necessary to
enable the sort procedure to get this information which I would like to
eliminate.

The TStringList custom sort routine has a means of passing you
information about the list in question. Better still is the Compare event
handler in the TListView and TTreeView components. Why couldn't TList's
sort be implemented like one of these?

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles