Jeremy Kister wrote:
I'm stumped on how to sort an array based on a hash refrences's key in
each element of my array.
this is dumbed down code of what I have:
my @array;
while(my $row = $sth->fetchrow_arrayref){
my %hash = (id => $row->[0], name => $row->[1]);
push(@array, \%hash);
}
after the while loop, I'm trying to build a new version of @array,
sorted by the 'name' key.
Anyone feel like throwing example code my way?
my @sorted = sort { $a->{ name } cmp $b->{ name } } @array;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>