> -----Original Message-----
> From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] 
> Sent: 17 September 2002 14:44
> To: [EMAIL PROTECTED]; Jeff Aa
> Cc: [EMAIL PROTECTED]
> Subject: Re: sorting a hash - multiple key fields
> 
> 
> Use this . I think you wud do better later to move the sort 
> function to 
> a seperate sub
> 
> foreach $key (sort {
>      ($$h{$a}{taste} eq $$h{$b}{taste} )  ? $$h{$a}{name} cmp 
> $$h{$b}{name}: $$h{$a}{taste} \cmp $$h{$b}{taste}
>      }  (keys %$h)) {
>      print "$key \n";
> }
> 
> 

Did you use the string comparisons 'eq' and 'cmp' deliberately on the
numeric values? Is this faster than a numeric compare? 

A little explanation on why you think the ? operator is more [efficient
| faster | better | clearer | other ] would be appreciated. 

You seem to be recommending returning a sorted list of keys, rather than
a sorted list of sub-hashes, and you are doing hash lookups inside the
sort function, using $a and $b as key values - surely this would be
slower than having $a and $b already loaded with hashrefs?

TIA
Jeff


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to