The Database Managers, Inc.

Contact The Database Managers, Inc.

Use an RSS enabled news reader to read these articles.Use an RSS enabled news reader to read these articles.

TList::Sort Example

Date: Mon, 31 May 1999 01:03:32 GMT
(copied and edited from a message posted on borland.public.cpp.language )

The original poster warns that the comparisons (<, > etc) may be backwards.

typedef TMyStructure* PMyStructure;

int __fastcall ComparisonFunction(void * Item1, void * Item2)
  if (PMyStructure(Item1)->Data < PMyStructure(Item2)->Data)
    return -1;
  if (PMyStructure(Item1)->Data > PMyStructure(Item2)->Data)
    return 1;
    return 0;

void __fastcall TForm1::FormCreate(TObject *Sender)
  TList* List = new TList();

  PMyStructure x = new TMyStructure();
  x->Data = 123;

  // etc

  // etc

  // delete list items + list

Popular C++ topics at The Database Managers:

The Database Managers has been providing custom programming services in since 1985. The types of projects they have worked on ranges from automated inventory control systems to intelligent systems that detect fraud in insurance claims.

Email them at to inquire about support for your project.


C++ FAQ Services | Programming | Contact Us | Recent Updates
Send feedback to: