in reply to Re: re-key a hash
in thread re-key a hash
@hash2{ 0 .. (keys %hash)-1 } = map { $hash{$_} } sort {$a <=> $b} key +s %hash;
You had it right before; why did you think you need the map there?
@hash2{ 0 .. (keys %hash)-1 } = @hash{ sort { $a <=> $b } keys %hash } +;
I'm too lazy to verify, but I think you don't need to assign to a separate hash if you do it this way, either. The list should be assigned atomically once it is built completely.
Makeshifts last the longest.
|
|---|