Mornin' Monks !! I come to seek wisdom.
I've tried a few different ways to sort a hash table according to the keys in the hash. What I mean specifically is this, If I enter the Keys of my hash like so, they should print out like so:
my %newHoA = (
"Sports" => ["Soccer","UltimateFrisbee","Basketball"],
"Books" => ["Cannery Row", "Animal Farm", "East of Eden"],
"Places" => ["BigSur","Zion", "CrateLake"] );
foreach my $keyHoA (<sort goes here> keys %newHoA) {
print "The key is: $keyHoA" . " And one value is: $newHoA{$req}[0]" .
+ "\n";
}
So the output should be something like:
The key is: Sports And the value is: Soccer
The key is: Books And the value is: Cannery Row
The key is: Places And the value is: BigSur
Well, I hope some monk out there has the wisdom I seek. Thanks.
UPDATE:
Thank you all for the suggestions. Its helpful to get different perspectives on a single problem.
"An incendiary Perl will solve that problem" :-) - myself
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.