----- Original Message ----- From: <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To: "Octavian Rasnita" <[EMAIL PROTECTED]>; <beginners@perl.org>
Sent: Monday, May 09, 2005 4:30 PM
Subject: Re: sorting a hash




----- Original Message ----- From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Monday, May 09, 2005 2:32 PM
Subject: sorting a hash



Hi,

I have a reference to a hash of hashes, something like:

[snip]

I want to sort the persons with the codes 'a', 'b', and 'c' by their name,
^^^^
and print something like:

"a has the name z and has 14 years".
... then the next person in  order...

foreach my $key (sort (keys %$ref)){
print "$key => $ref->{$key}{name} is $ref->{$key}{age}\n";
}

Unless I'm in error, the requirement was to sort the results in order by name, not by the key :-)




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to