If you don't want to call sort repeatedly, save the result.
my @sorted_keys = sort { $a <=> $b } keys(%foo);
Update: Or if you no longer need the keys:
my @sorted_values = @foo{ sort { $a <=> $b } keys(%foo) };
In reply to Re: Permanently sort a hash
by ikegami
in thread Permanently sort a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |