sort dateTime problem

Timothy Miller gandalf at
Fri Dec 16 15:46:16 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.
>>This seems like a flaw in the way Rev interprets certain dates, 
>>under certain circumstances.

jacque at replied:

>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.

That's a pretty smart engine.

>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.

Okay, that seems more or less consistent with what is happening.

OTOH, I'm not sure this explains why "<space>4/19/05" would convert 
to a negative number of seconds, assuming the date in question is one 
in a well-formatted sequence of dates.

But I don't need to understand that. The main thing is that it's not 
a bug that RR should fix.

>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.

Understood. This kind of inconsistency might be the price the user 
pays for RR's flexibility when it comes to reporting, converting and 
interpreting dates and times.

This "gotcha" should be documented, though.

>You could fix your sort command this way:
>   sort lines of cd fld "shedule.2" datetime by word 1 of item 2 of each

Good idea. I wouldn't have thought of that.

Thanks to you and Jim, too, for your assistance.


More information about the Use-livecode mailing list