in reply to Sorting based on filesize.
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting based on filesize.
by grinder (Bishop) on Jul 20, 2004 at 06:28 UTC | |
by eyepopslikeamosquito (Archbishop) on Jul 20, 2004 at 08:41 UTC | |
by merlyn (Sage) on Jul 20, 2004 at 13:20 UTC | |
by pbeckingham (Parson) on Jul 21, 2004 at 00:46 UTC |