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 },
>         { ID => 10111, UserID => 1211, Status => 2 },
>         { ID => 10721, UserID => 1198, Status => 1 }
> );
> 

<example>
#!/usr/bin/perl -w

use strict;
use Data::Dumper;

my @AoH = (
        { ID => 10101, UserID => 1041, Status => 2 },
        { ID => 10541, UserID => 1211, Status => 1 },
        { ID => 10111, UserID => 1211, Status => 2 },
        { ID => 10721, UserID => 1198, Status => 1 }
);

print Dumper($_) for (sort { $a->{ID} <=> $b->{ID} } @AoH);
</example>


-- 
Today is Boomtime the 37th day of Chaos in the YOLD 3168
You are what you see.

Missle Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to