Hi,
Try something like this
d = Dir.open(’/user/path/Documents’)
d.entries.sort
=> [ “.”, “…”, “doc1”, “doc2”, etc ]
for some reason block processing is counter intuitive here
this code does not work
e = Dir.open(’/user/path/Documents’)
e.entries.sort {|file| puts file }
=> warning: multiple values for a block parameter (2 for 1)
Regards,
joe
----- Original Message ----
From: Brad [email protected]
To: ruby-talk ML [email protected]
Sent: Friday, March 9, 2007 7:35:05 PM
Subject: Find.find — returns directories/files backwards
New user question:
It seems to me when I run:
Find.find(’/user/name/documents’) {|path| puts path}
it returns all the directories in the reverse order. I was expecting
the directories to be returned in alphabetical order, but that doesn’t
seem to be the case. Also, in one case it reads half of a directory’s
files, then the sub dirs and then it finished reading the rest of the
directory it started in and finished writing them in the Puts
statement.
Am I missing something? How do you do get it to write out the
directories in alphabetical order?
Any and all help welcome.
Thank you.
Brad