in reply to Modifying order of a hash
Hash of Hashes or Array of Hashes? Or Hash of Arrays which is what your syntax suggests?
Lets say it is an array of hashes:
my @new; foreach $fn (@old) { $new[$fn->{FirstNum}]= $fn; delete $fn->{FirstNum}; }
If it is a hash of hashes:
my %new; foreach $fn (keys %old) { $new{$fn->{FirstNum}}= $fn; delete $fn->{FirstNum}; }
UPDATE: As an afterthought: Use Data::Dumper. It will show you the right syntax you should have used in your question. And also it will tell you which of the wildly different answers posted in this thread does what you need, if you use it to print the data structure before and after.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Modifying order of a hash
by monaghan (Novice) on Sep 25, 2008 at 21:01 UTC | |
by jethro (Monsignor) on Sep 25, 2008 at 21:55 UTC | |
by monaghan (Novice) on Sep 25, 2008 at 23:00 UTC | |
by jethro (Monsignor) on Sep 25, 2008 at 23:37 UTC | |
by monaghan (Novice) on Sep 26, 2008 at 00:11 UTC |