i'm writing a simple application that inserts records into a database, sorted according to date (a UInt32). my compare function is simple:

static Int16 mycompare(dbrecord *dbr1, dbrecord *dbr2, Int16 arbitrary, SortRecordInfoPtr r1info, SortRecordInfoPtr r2info, MemHandle appinfo)
{
return (dbr1->date - dbr2->date);
}

My guess is that something else is going wrong, but you also need to fix your comparison code. Whenever you're sorting unsigned values, you don't want to rely on straight subtraction. Instead you'd do something like:


        if (dbr1->date < dbr2->date) {
                return(-1);
        } else if (dbr1->date > dbr2->date) {
                return(1);
        } else {
                return(0);
        }

-- Ken
--
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200

--
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to