XP is just a number | |
PerlMonks |
Re: Sorting perl hashby johngg (Canon) |
on Mar 06, 2021 at 18:31 UTC ( [id://11129206]=note: print w/replies, xml ) | Need Help?? |
Your line for my $key1 (keys %rankBased) { implies that you have an HoHoH structure to start with and, as others have mentioned, you can't have "ordered" hashes without a bit of jiggery-pokery. To retain a sorted order you need to introduce an array in there somewhere. The following code constructs an HoAoHoH structure, inserting an array between your $key1 and $key2 so that the sort is preserved.
The Data::Dumper output.
I hope this guess at your data and intentions is helpful. Update: Changing the map line to
will work if the innermost hashes have multiple key/value pairs. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|