SavannahLion has asked for the wisdom of the Perl Monks concerning the following question:
I'm pretty sure I spotted this snippet somewhere but now I can't recall where or how this is done.
Is there a more elegant way to obtain a key ordered list or array hash values.
In other words,
A) Order the hash based on keys
B) return a list of the values based on their key order.
#unrelated code here my @data; for (sort keys %ABC) { push(@data, $ABC{$_}); } return @data;
Any ideas on this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Return values from a key sorted hash
by BrowserUk (Patriarch) on Sep 10, 2010 at 22:11 UTC | |
|
Re: Return values from a key sorted hash
by Your Mother (Archbishop) on Sep 10, 2010 at 21:48 UTC | |
|
Re: Return values from a key sorted hash
by roboticus (Chancellor) on Sep 10, 2010 at 22:15 UTC | |
by BrowserUk (Patriarch) on Sep 10, 2010 at 22:23 UTC | |
by roboticus (Chancellor) on Sep 10, 2010 at 23:56 UTC | |
|
Re: Return values from a key sorted hash
by dasgar (Priest) on Sep 10, 2010 at 21:53 UTC | |
|
Re: Return values from a key sorted hash
by SavannahLion (Pilgrim) on Sep 11, 2010 at 00:14 UTC | |
by ikegami (Patriarch) on Sep 11, 2010 at 02:39 UTC |