perlcat has asked for the wisdom of the Perl Monks concerning the following question:
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) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort hash by key length and alphabetically
by moritz (Cardinal) on Jul 22, 2010 at 06:51 UTC | |
|
Re: Sort hash by key length and alphabetically
by salva (Canon) on Jul 22, 2010 at 06:54 UTC | |
|
Re: Sort hash by key length and alphabetically
by davido (Cardinal) on Jul 22, 2010 at 08:45 UTC |