in reply to re-key a hash
$hash{-10} = 'bar'; $hash{-1} = 'foo'; $hash{12} = 'baz'; %hash = map { (keys %hash) - 1 => delete $hash{$_} } sort {$b <=> $a} keys %hash; print map {"$_ => $hash{$_}\n"} sort { $a <=> $b } keys %hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: re-key a hash
by Aristotle (Chancellor) on Aug 02, 2004 at 22:19 UTC | |
by tye (Sage) on Aug 03, 2004 at 01:11 UTC | |
by ccn (Vicar) on Aug 02, 2004 at 22:33 UTC |