From: Clemens Hintze Date: 2000-12-09T18:10:07+09:00 Subject: [ruby-talk:6959] Re: Dir.sort(somedir) ? >>>>> "Dave" == Dave Brondsema writes: Dave> I just started experimenting with Ruby tonight and have Dave> written a decent sized program in just a few hours. Congratulations :-) (...) Dave> Dir.foreach(thisdir) { Dave> |filename| # do stuff with filename Dave> } Dave> How can I change this so that it iterates through the Dave> alphabetically sorted directory? Dave> If I could get the directory into an array, I think I could Dave> sort it using arrayname.sort and then iterate through it. Dave> However, I don't even know how to do that. No problem, try this: filelist = Array.new Dir.foreach(thisdir, &filelist.method(:push)) filelist.sort.each do |filename| # do stuff with filename end Dave> Thanks in advance, You're welcome and much fun with Ruby ... :-) Dave> -- Dave Brondsema \cle