472,119 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.


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

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 1489

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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.