I am using the code below to sort a hash by the length of its keys in ascending order.
On top of that, I would like the keys to be also sorted alphabetically.
Could someone help me out? Many thanks.
foreach my $key (sort hashKeyLengthAsc (keys(%count))) [...] } sub hashKeyLengthAsc { length($a) <=> length($b) }
In reply to Sort hash by key length and alphabetically by perlcat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |