Look at the three file test operators -M, -A and -C and decide which of them best mirrors your "time created". Let's assume it's -M.
The naive way to sort a list of files then becomes:
my @sorted_files = sort { -M $a <=> -M $b } @files;
But you specifically asked for an efficient method, so you'll probably want to replace that with an Orcish Maneuver or a Schwartzian Transform. See Uri Guttman and Larry Rosler's excellent paper for discussion of these methods and other Perl sorting mechanisms.
Also, you have this code:
opendir (LOWEST, "<$input_directory_lowest")
I think you're confusing open and opendir. for opendir you don't need the '<' on the directory name. In fact, I'm surprised to see that it works.
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: sorting files by date
by davorg
in thread sorting files by date
by Win
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |