in reply to mysql sorting
(not tested, but seems simple enough)my $sth = $dbh->prepare( "select group, somedata from sometable" ); $sth->execute; my $rowrefs = $sth->fetchall_arrayref; my %grouphash; for my $row ( @$rowrefs ) { push @{$grouphash{$$row[0]}}, $$row[1]; } for my $group ( sort keys %grouphash ) { print "$group\n"; print " $_\n" for ( sort @{$grouphash{$group}} ); }
updated to fix brackets on $$row[1] (I didn't mean to use curlies there).
|
|---|