Edgar T. López wrote:
You're right. Thanks.
Now, I'm using the DateTemplateToAscii function to give a format to the date, because I need only two digits to the day, month and year with zeros.
DateTemplateToAscii("^4s_^3z_^0z",curDateTime.month,curDateTime.day,curDateTime.year,sToday,20);
And I would like to do the same with the time; because the SysQSort does not do
the order correctly.
For example(YY_MM_DD_hh.mm.ss):
05_06_24_8.30.07
05_06_24_3.05.04
05_06_24_10.30.05
05_06_24_10.30.01
Instead of:
05_06_24_10.30.05
05_06_24_10.30.01
05_06_24_8.30.07
05_06_24_3.05.04
Could you help me?. Thanks.
Best Regards.
Edgar T. López
That's because the sort you are using is comparing them as strings. You
want it to be descending, where "10" should be greater than "8", but
when talking about strings, "1" is LESS than "8". So either you need to
express the strings in a way that will sort correctly (something like
"05_06_24_08.30.07" instead of "05_06_24_8.30.07") or have your
comparison function compare the dates first as text, and if the dates
are the same then compare the times taking into account the formatting
of the time.
It sounds like you are translating the data into text just for the
comparison, and I wouldn't do it that way. You don't need to translate
either into text before comparing. You could just compare the date and
time numbers directly, or perhaps both parts are contained within a
single UInt32 time register (like the number you get with a call to
TimGetSeconds()) in which case you just compare that number. Once the
sorting is done, then you can translate the resulting list into their
respective text strings.
Bob.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/