[REBOL] Re: files out of order
From: gjones05:mail:orion at: 29-Mar-2001 14:07
> I have a directory of XML-formatted messages,
> each saved with a numeric
> filename based on the time of creation, for example
> I use the following function to read the directory
> and to create a block of file names, with the
> intention of placing the newest files first in the
> block (in other words, the files with the highest
> number first in the block.)
> read-directory-messages: func [
> "Read a directory of XML-formatted standard messages with the
> determined by messageType."
> message-directory [block!] "A block of file names corresponding to a
> directory of XML-formatted standard messages."
> message-block: copy 
> foreach file-name message-directory [
> file-contents: read file-name
> insert message-block file-contents
> But using the above function, I get files showing up in the block out of
> order. Am I doing something wrong?
> Ryan C. Christiansen
If I understand your intention correctly (which is a big assumption for me
on some days :-), then I would suggest reverse sorting the file names before
using the foreach block. For example, add this line before the foreach:
The file names should then be sorted largest first, therefore allowing the
foreach to iterate through the block in this order. Worth a try anyway.