Hello all,
Howdy.
When I populate this hash (%SrcIDs) from "SELECT id, desc, from myTable order by desc" it doesn't order by the description field "desc". (printing each row in the while loop show that the SQL is sorted)
See inlined change below.
while( my($id, $desc) = $sth->fetchrow ) { $SrcIDs{$id} = $desc; } $sth->finish;
my @Sources = keys(%SrcIDs);
my @Sources = sort { $SrcIDs{$a} cmp $SrcIDs{$b} } keys %SrcIDs;
That's a pretty basic sort(). If you would like more information about how it works, try feeding your command line:
perldoc -f sort
Hope that helps.
James
# Begin HTML print header('text/html'); print start_html('Select Source Mill Info Page'), h3('Select Source Mill'), startform('GET','srcmill.cgi','','gosrcmill','_blank'), "Source Mill:  ", popup_menu('millid', [EMAIL PROTECTED], '', \%SrcIDs),p, ...
So, you see I want to link @Sources with the keys of %SrcIDs, but what I want is to sort the hash alphabetically by the values of %SrcIDs. Please, how can I do that?
Cheers.
Scott.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>