in reply to Re: Re: Mind Bending Arrays
in thread Mind Bending Arrays
If you really need to put this in an array (to keep track of the insertion order, for example), you could probably do it like this:my %hash; while (my ($filename, $number) = &get_both) { $hash{$filename} = $number; } my @sorted_files = sort { $hash{$a} <=> $hash{$b} } keys %hash;
my @array; while (my ($filename, $number) = &get_both) { push(@array, [ $filename, $number ]); } my @sorted = sort { $a->[1] <=> $b->[1] } @array;
|
|---|