in reply to Re: sorting tree with folders on top
in thread sorting tree with folders on top

my mistake. it should be:
my @arr = ( { 'path' => '/c/', dir => '/' }, { 'path' => '/c/a1.mp3', 'file' => 1, 'dir' => '/c' }, { 'path' => '/c/a2.mp3', 'file' => 1, 'dir' => '/c' }, { 'path' => '/c/bb/aa1.mp3', 'file' => 1, 'dir' => '/c/bb' }, # th +is is /c/bb { 'path' => '/c/bb/aa2.mp3', 'file' => 1, 'dir' => '/c/bb' }, # th +is is /c/bb { 'path' => '/c/bb/', 'dir' => '/c' }, { 'path' => '/c/cc/', 'dir' => '/c' }, { 'path' => '/c/aa/', 'dir' => '/c' } );
key "dir" is only here to make it faster to compare where which file/subfolder is located. dir is nothing else but everything from the path until last slash. path =~ s/^(.*)(\/.*)$/$1/;