If you are using a small hash do not bother about the load
If you are going to use huge hashes I think you should create subhashes
or sorted arrays on the fly using *map* . I personally am not very
fluent with map I think you will get better help on the mailling list
with a more direct question


On Tue, 2002-09-17 at 19:58, Jeff AA wrote:
> 
> > -----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
> 
-- 
Ramprasad A Padmanabhan
Sr Software Engineer
Netcore Solns Pvt Ltd
Mumbai
ph - (022) 4628000


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

Reply via email to