If you are able to ... then change your data! :)
my %hash = ( EX => { sort => 30, data => 'ArraySite' }, AM => { sort => 40, data => 'IOPort' }, PLE => { sort => 20, data => 'AddressGroup' }, Number => { sort => 1, data => '11' }, ); for my $key (sort { $hash{$a}->{sort} <=> $hash{$b}->{sort} } keys %ha +sh) { print $key, " => ", $hash{$key}->{data}, "\n"; }
What happens when 'Number' has to be renamed, or another key is added whose length is longer than 'Number?' I would first try to make the data work for me rather than the other way around, if possible.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Hash Order
by jeffa
in thread Hash Order
by Sporti69
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |