Sorting



Hi,

I'm looking to read a directory to get a list of files in Descending
sorted order by timestamp. I've gotten this so far, but it is in
ascending. Can anyone help with the descending part?

my $dir = '/home/logfiles';

opendir my $DH, $dir or die "Cannot opendir '$dir' $!";

my @sorted_files =
map $_->[1],
sort { $a->[0] <=> $b->[0] }
map -f "$dir/$_" ? [ ( stat _ )[9], $_ ] : (),
readdir $DH;

for ($i=0; $i<20; $i++) {
print "FILE: $sorted_files[$i]\n";
}


Thank a bunch!
.



Relevant Pages

  • Re: Sorting
    ... sorted order by timestamp. ... ascending. ... Can anyone help with the descending part? ...
    (comp.lang.perl.misc)
  • Re: Sorting
    ... Quoth ExecMan: ... I'm looking to read a directory to get a list of files in Descending ... sorted order by timestamp. ...
    (comp.lang.perl.misc)