You need the Schwartzian Transform. It precomputes the sizes of all the files, and performs sorting based on the precomputed values, reducing the number of times it would otherwise read file size from the disk.
my @sorted = map {$_->[0] } sort {$a->[1] <=> $b->[1]} map {[$_, -s] } @files;
In reply to Re: Sorting based on filesize.
by pbeckingham
in thread Sorting based on filesize.
by heigold1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |