RE: Sorting an array of hashes

2004-08-06 Thread Chris Mortimore
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes 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 t

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: Gunnar Hjalmarsson wrote: Chris Mortimore wrote: 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. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky...

Re: Sorting an array of hashes

2004-08-05 Thread Randy W. Sims
On 8/5/2004 5:18 PM, Chris Mortimore wrote: 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 o

RE: Sorting an array of hashes

2004-08-05 Thread Moon, John
-Original Message- From: Chris Mortimore [mailto:[EMAIL PROTECTED] Sent: Thursday, August 05, 2004 5:19 PM To: [EMAIL PROTECTED] Subject: Sorting an array of hashes 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

RE: Sorting an array of hashes

2004-08-05 Thread Chris Devers
On Thu, 5 Aug 2004, Chris Mortimore wrote: Gunnar Hjalmarsson wrote: > Chris Mortimore wrote: >> 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. > > The value of one of the keys? If you don't know *which* key in > respective hash, th

RE: Sorting an array of hashes

2004-08-05 Thread Chris Mortimore
Chris Mortimore wrote: > 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. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.g

Re: Sorting an array of hashes

2004-08-05 Thread Gunnar Hjalmarsson
Chris Mortimore wrote: 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. The value of one of the keys? If you don't know *which* key in respective hash, this appears to be pretty tricky... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc

RE: Sorting an array of hashes

2002-02-06 Thread Tomasi, Chuck
06, 2002 1:28 PM > To: 'Tomasi, Chuck'; '[EMAIL PROTECTED]' > Subject: RE: Sorting an array of hashes > > > @sorted = sort { > $a->{ID} <=> $b->{ID} ## remember that $a and $b > become the element > of the array > ## so if

Re: Sorting an array of hashes

2002-02-06 Thread Brett W. McCoy
On Wed, 6 Feb 2002, Tomasi, Chuck wrote: > Does anyone have any clever ideas for sorting an array of hashes based on > a key such as an ID number? > > Example: > > @AoH = ( > { ID => 10101, UserID => 1041, Status => 2 }, > { ID => 10541, UserID => 1211, Status => 1 }, > { ID

Re: Sorting an array of hashes

2002-02-06 Thread Shawn
- Original Message - From: "Tomasi, Chuck" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 06, 2002 1:17 PM Subject: Sorting an array of hashes > Does anyone have any clever ideas for sorting an array of hashes based on > a key such as an ID number? > > Example:

Re: Sorting an array of hashes

2002-02-06 Thread Chas Owens
On Wed, 2002-02-06 at 14:17, Tomasi, Chuck wrote: > Does anyone have any clever ideas for sorting an array of hashes based on > a key such as an ID number? > > Example: > > @AoH = ( > { ID => 10101, UserID => 1041, Status => 2 }, > { ID => 10541, UserID => 1211, Status => 1 }, >

RE: Sorting an array of hashes

2002-02-06 Thread Nikola Janceski
@sorted = sort { $a->{ID} <=> $b->{ID} ## remember that $a and $b become the element of the array ## so if it's a reference to a hash use a dereferencer '->' or # $$a{ID} <=> $$b{ID} # will work too! } @AoH; foreach $item (@sorted){ print $item->{