Sorting an array of hashes

From: Chris Mortimore (CMORTIMR_at_graceland.edu)
Date: 08/05/04


Date: Thu, 5 Aug 2004 16:18:57 -0500
To: <beginners@perl.org>

I want to sort an AoH. Not each hash by its keys, but the array by the
value of one of the keys in each hash.
I know how to sort a simple array.
I know how to sort a hash by the keys.
Could someone kindly point me to the documentation on sorting arrays of
hashes?
 
Thank you!
Chris.
 
>>>-----> <-----<<<
Chris Mortimore
Information Services
Graceland University
cmortimr at graceland dot edu
 



Relevant Pages

  • Re: Sorting a Hash of Arrays by an Element in the Array
    ... > Alf McLaughlin wrote: ... >> element of the array will be sorted in. ... > Your example would only sort numbers correctly. ... but since you can always sort a hash who really cares? ...
    (comp.lang.perl.misc)
  • Re: HOA redundancy in array.
    ... creates a new hash called $saw. ... corresponding to the given keys. ... [Given that @HOH_protein is an array, therefore $pro_name is a number, ... for my $got (@uniqs) { ...
    (comp.lang.perl.misc)
  • Re: Create list of variables to be printed?
    ... but I wasn't able to sort out the proper syntax. ... I guess I could create a hash with just the variables I ... with the keys being numbers. ... >> Then you sort the keys or make the hash a little more dynamic. ...
    (perl.beginners)
  • Re: populating a hash with % used as the key and F string as the value
    ... > keys %lookup; ... it states one cannot push or pop a hash on page 10 ... itself is the reference to the array (read: an arrayref). ...
    (perl.beginners)
  • Re: maintaining order in a hash (without Tie::IxHash)
    ... Save the keys in a separate array and iterate over the array. ... >> is the simplest approach at the expense of duplicate storage of the ... accessing a large hash by sorting a ...
    (comp.lang.perl.misc)