this code should do it:
#!/usr/bin/perl use strict; use warnings; use File::Basename; my @files; while(<>) { chomp; push @files, $_; } sub fcmp { my $res = dirname($a) cmp dirname($b); $res = basename($a) cmp basename($b) unless $res; return $res; } my @sorted = sort fcmp @files; print "$_\n" for @sorted;
Update: note that array should contain only filenames, if there are directory names it will not work correctly.
In reply to Re: Sorting Directory and Filenames
by zwon
in thread Sorting Directory and Filenames
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |