in reply to how do I sort on two fields in a hash table?
If @data is large you may want to use a Schwartzian Transform (or other method of improving sort performance).foreach $junk (sort {$b->{'count'} cmp $a->{'count'} or $b->{'type'} cmp $a->{'type'}} @data) { print "$junk->{'count'} --> $junk->{'type'} --> $junk->{'a_point +'} -> $junk->{'z_point'} --> $junk->{'error'}\n"; }
BTW, @data would more properly be called a "list of hashes".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: how do I sort on two fields in a hash table?
by dvergin (Monsignor) on Mar 15, 2001 at 22:58 UTC | |
|
Re: Re: how do I sort on two fields in a hash table?
by knobunc (Pilgrim) on Mar 16, 2001 at 00:14 UTC | |
by lhoward (Vicar) on Mar 16, 2001 at 01:43 UTC | |
by vonman (Acolyte) on Mar 16, 2001 at 00:50 UTC | |
by larryl (Monk) on Mar 16, 2001 at 01:16 UTC | |
|
Re: Re: how do I sort on two fields in a hash table?
by vonman (Acolyte) on Mar 16, 2001 at 00:51 UTC | |
|
Re: Re: how do I sort on two fields in a hash table?
by vonman (Acolyte) on Mar 15, 2001 at 22:51 UTC |