Hashes won't preserve order. You can use Tie::IxHash, which sets up a different, order preserving, data structure with hash semantics.
You could keep a sorted array of keys from your hash, instead.
my @key_sorted = sort keys %hash; #or my @val_sorted = sort {$hash{$a} cmp $hash{$b}} keys %hash;
After Compline,
Zaxo
In reply to Re: Hash sorting
by Zaxo
in thread Hash sorting
by pickledegg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |