in reply to Re: how do I sort on two fields in a hash table?
in thread how do I sort on two fields in a hash table?
(Note the parentheses above indicating the binding).( sort {$b->{'count'} cmp $a->{'count'} ) or $b->{'type'} cmp $a->{'type'}} @data
What you want is:
Which binds more tightly. I also flipped the comparison operator for count since as dvergin pointed out above you probably want a numeric comparison for count.sort {$b->{'count'} <=> $a->{'count'} || $b->{'type'} cmp $a->{'type'}} @data
-ben
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: how do I sort on two fields in a hash table?
by lhoward (Vicar) on Mar 16, 2001 at 01:43 UTC | |
|
Re: Re: Re: how do I sort on two fields in a hash table?
by vonman (Acolyte) on Mar 16, 2001 at 00:50 UTC | |
by larryl (Monk) on Mar 16, 2001 at 01:16 UTC |