If the sort field is just a hash key lookup, its not worthwhile to do the Schwartzian thing (even with the hash dereference). You have to build an array reference, and then dereference it, so its only worth it for more expensive operations. Just do a straight sort:<code> sort { $thishash->{$b} <=> $thishash->{$a} } keys %thishash;foreach my $key (map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_, $thishash->{$_} ] } keys %$thishash;
In reply to Re: Re: problem in sorting has by value
by runrig
in thread problem in sorting hash by value
by an_mo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |