Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TListSortCompare question...

Status
Not open for further replies.

syrianska

Programmer
Joined
Apr 28, 2003
Messages
1
Location
SE
Hi,

I'm trying to sort two objects with the TListSortCompare function, but I can't make the function work, and the help files are not helping. I want to sort a TList comparing the score two objects have. Anybody who can give me a pointer??

typedef int __fastcall (*TListSortCompare)(void * Item1, void * Item2);

Thanks / J
 
This is a Delphi/CB question, not an InterBase one...

But, you should have a function like this (Delphi):

function MyCompare(Item1, Item2: Pointer): Integer;
var MyObject1, MyObject2: TMyObject;
begin
MyObject1 := TMyObject1(Item1);
MyObject2 := TMyObject1(Item2);
if MyObject1.Score > MyObject2.Score
then Result := 1
else if MyObject1.Score < MyObject2.Score
then Result := -1
else Result := 0; // equal
end;

Martijn Tonies
Database Workbench - the developer tool for InterBase and Firebird
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top