If we're using multiple statements anyway (not doing so was the point of my obscure ditty), I'd shuffle things around.
{ my @key = sort { $a <=> $b } keys %h; @h{ 0 .. $#key } = delete @h{ @key }; }
That seems like a cleaner separation of concerns. The symmetry of the second line here seems more pleasing and makes it more robust — it remains valid regardless of how the list of keys is generated.
Makeshifts last the longest.
In reply to Re^3: re-key a hash
by Aristotle
in thread re-key a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |