-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
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...
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
-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
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
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
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
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
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
- 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:
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 },
>
@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->{
12 matches
Mail list logo