danj35 has asked for the wisdom of the Perl Monks concerning the following question:
Hi
Been stuck on this small problem for a while now and wondered if anyone can help. I have a hash where the keys all begin with E followed by a number, e.g. E47. I need to sort through this hash so that it goes E1, E2... E59 and so on, while it iterates through the foreach loop. The best I can think of is this, but it only compares the second char.
foreach my $key (sort { $a cmp $b } keys %full){ }
I imagine there's a simple solution, any help would be greatly recieved.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sort after first char of hash key
by wind (Priest) on Jun 02, 2011 at 14:48 UTC | |
by danj35 (Sexton) on Jun 02, 2011 at 16:37 UTC | |
|
Re: sort after first char of hash key
by Cristoforo (Curate) on Jun 03, 2011 at 00:38 UTC | |
|
Re: sort after first char of hash key
by thundergnat (Deacon) on Jun 02, 2011 at 18:18 UTC |