Edgar T. López wrote:
Hi Logan,
When you say "Use SysQSort", you tried to say to me that I need to create
the Quick Sort function or already exists the function of QuickSort to use.
SysQSort will sort a block of memory based on the sorting function that
you provide. There is no generic sorting function, so you DO have to
create one. Below is some sample code that will take a list of databases
(a list of cardNo and LocalID) and then sort that list by database
name. Note that the list does NOT contain the database names, but the
sort function finds the database names and uses them for the comparison.
Bob.
SysQSort (dbListP, dbCount, sizeof(myDbListType), myCompareDBNames, 0);
which uses the following definitions/functions:
typedef struct {
UInt16 card;
LocalID id;
UInt16 other;
} myDbListType;
Int16 myCompareDBNames (void *a, void *b, Int32 other)
{
myDbListType *a1=a;
myDbListType *b1=b;
Char *st1=MemPtrNew(33);
Char *st2=MemPtrNew(33);
Err err;
Int16 result;
st1[0]=0;
st2[0]=0;
err = DmDatabaseInfo(a1->card, a1->currentDB,
st1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
err = DmDatabaseInfo(b1->card, b1->currentDB,
st2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
result=StrCompare(st1,st2);
MemPtrFree(st1);
MemPtrFree(st2);
return result;
}
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/