Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting an ADIR by date modified
Message
 
 
To
21/10/2008 11:38:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01356078
Message ID:
01356091
Views:
24
Mike,

Some sorting algorithms (called Stable sorting algorithms) preserve the order of the records with the same sort key and other don't. Seems that VFP uses the later.
A little bit simpler expression
  aa[i, 5] = CTOT(TRANSFORM(DTOS(aa[i,3]), "@R 9999-99-99") + "T" + aa[i,4])
>I was hoping
>
>=aSort(aa, 4)
>=aSort(aa, 3)
>
>would work, by first sorting the times, then the dates, leaving the time as a sub-sort.
>
>I still don't understand why it doesn't work, to be honest, but it doesn't.
>
>
>>Never mind.
>>
>>>
>>>I just wrote this to sort an adir array by datetime modified.
>>>
>>>If I'm not mistaken, this should avoid any problem with ambiguous dates despite using CTOT().
>>>
>>>But it seems like a clunky way to do it. I figured I'd just ask for fun if there are any other creative ways of doing this.
>>>
>>>
>>>nFiles = ADIR(aa)
>>>FOR i = 1 TO nFiles
>>>aa[i, 5] = DATETIME(YEAR(aa[i, 3]), MONTH(aa[i, 3]), DAY(aa[i, 3]), ;
>>>	HOUR(CTOT(aa[i, 4])), MINUTE(CTOT(aa[i, 4])), SEC(CTOT(aa[i, 4])))
>>>ENDFOR 
>>>=ASORT(aa, 5)
>>>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform