Thanks for the response - some questions on your recommendation below:
-----Original Message-----
From: david [mailto:[EMAIL PROTECTED]]
Sent: 17 September 2002 19:06
To: [EMAIL PROTECTED]
Subject: Re: sorting a hash - multiple key fields
> the return statment is uneccessary. try something like:
> foreach my $k (sort {$h->{$a}->{taste} <=> $h->{$b}->{taste} ||
> $h->{$a}->{name} cmp $h->{$b}->{name}} keys
%{$h}){
> print "$h->{$k}->{name} $h->{$k}->{taste}\n";
> }
I had wondered about an || - lazy eval et al - would it be [better | no
different] using lower precedence 'or'? Using 'return' seems to
generalise better when I have a whole list of sort fields, as it can be
used in a loop construct?
You are the second person to suggest passing keys into the sort sub, and
getting it to lookup the child-hash - it seems to me it would be way
more efficient to pass in the hash values and not bother with the
lookup?
Thanks for the feedback,
Regards
Jeff
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]