I need to execute the following code in ruby:
<%
files = Dir.glob('/**/*')
files.each do |file|
puts file
end
%>
It outputs (for example):
/dirA/file1.txt
/dirA/file2.txt
/dirB/file1.txt
/file1.txt
/file2.txt
/subdirA/file1.txt
I want him to output it as follows:
/file1.txt
/file2.txt
/dirA/file1.txt
/dirA/file2.txt
/dirB/file1.txt
/subdirA/file1.txt
Basically, I would like files to appear in front of directories. Is there a sort command that I can use?
source
share