469,085 Members | 950 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,085 developers. It's quick & easy.

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?

Nov 11 '05 #1
0 1304

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kamilche | last post: by
4 posts views Thread by its me | last post: by
reply views Thread by Sebastian Faust | last post: by
40 posts views Thread by Elijah Bailey | last post: by
3 posts views Thread by Seeker of the Unseen | last post: by
7 posts views Thread by Stuart | last post: by
7 posts views Thread by DC Gringo | last post: by
48 posts views Thread by Alex Chudnovsky | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.