in reply to Re: sorting files by date and names
in thread sorting files by date and names

How would you modify that to sort by creation time and then by modification time?

Replies are listed 'Best First'.
Re^3: sorting files by date and names
by jdporter (Paladin) on Mar 20, 2006 at 11:16 UTC

    Well, [stat]->[10] gives the "creation" time, and the modification time is in 9; so you could do this:

    my @sorted_files = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } map { [ $_, [stat]->[10], [stat]->[9] ] } @files;

    But for some reason, I'm tempted to do this:

    my @sorted_files = map { $_->[0] } sort { $a->[11] <=> $b->[11] or $a->[10] <=> $b->[10] } map { [ $_, stat ] } @files;
    We're building the house of the future together.