Board index » delphi » Array Sorting

Array Sorting

For the life of me I can't find a quick/easy way to sort arrays
in Delphi.

In C I just did the following, is there a similar method in delphi
somewhere?

int sort_ts(const void *e1, const void *e2)
{
  return strcmp( ((const Ttsrec *)e1)->Field1,
                 ((const Ttsrec *)e2)->Field1);

Quote
}

void Somefunction()
{
   Ttsrec tsrec[1000];

   //load some values here.

   // sort the array
   qsort(tsrec,tscnt,sizeof(tsrec[0]),sort_ts);

Quote
}

 

Re:Array Sorting


In article <378360a1.9076...@news.saix.net>, god.ner...@lords.com (Lord Damon

Quote
Fireblade) writes:
>For the life of me I can't find a quick/easy way to sort arrays
>in Delphi.

>In C I just did the following, is there a similar method in delphi
>somewhere?

In Classes.pas there's a couple of QuickSort procedures (one a general
procedure the other a private method of TStringList) which you could copy and
modify for your own use.

Alan Lloyd
alangll...@aol.com

Other Threads