Nobuyoshi Nakada
4/28/2009 3:33:00 AM
Hi,
At Tue, 28 Apr 2009 11:42:07 +0900,
Dafydd Fontenot wrote in [ruby-talk:335235]:
> Here's what the script looks like
> test = Array.new
>
> `find /folder/place -type f`.split("\n").each do |file|
> test.push(file)
> end
>
> test.sort_by { |file| file.gsub(/[^\/]/, "").length }
> puts test
Array#sort_by returns sorted new array, but doesn't change the
receiver itself.
require 'find'
test = []
Find.find("/folder/place") {|file| test.push(file) if File.file?(file)}
puts test.sort_by {|file| file.count("/")}
--
Nobu Nakada