sort dateTime problem

J. Landman Gay jacque at hyperactivesw.com
Thu Dec 15 23:12:45 EST 2005


Timothy Miller wrote:

> I just did quite a bit of haphazard troubleshooting. I isolated the 
> problem. The short dates are all preceded by a spacebar character. If I 
> remove the spacebar characters, the sort works correctly. This is easily 
> reproduced. It doesn't seem to matter whether items, lines or words are 
> being sorted.
<snip>
> 
> This seems like a flaw in the way Rev interprets certain dates, under 
> certain circumstances.
> 
> Comments?

It's correct behavior, based on the way that Rev calculates variable 
types automatically. Dates are composed of numbers and a date delimiter 
(usually "/" in the US). When the sort command sees a list of dates that 
are well formatted, it sorts them as expected. But if there is a leading 
space, the engine interprets it as an ascii string instead -- since 
there are not suppoed to be spaces in dates -- and you get an 
alpha-numeric sort.

If there is a bug at all, it is in the fact that Rev returns "true" if 
you ask it whether "  1/1/11" is a date. So it is smart about "is a 
date" but doesn't apply the same filtering to the sort routine. I'm not 
sure I'd exactly call this a bug as much as an inconsistency.

You could fix your sort command this way:

   sort lines of cd fld "shedule.2" datetime by word 1 of item 2 of each

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the Use-livecode mailing list