in reply to Sorting my hashref by value for printing a popup_menu using CGI
sub select_your_school { my $namesref = shift; # create a list of sorted hash keys my @menuitems = sort keys %$namesref; print $q->header, $q->start_html(-title=> 'Select Your School'), "Please select your school from the following list:", $q->start_form, $q->popup_menu( {-name => 'school_id', -values => \@menuitems , }), ....
sub select_your_school { my $namesref = shift; print $q->header, $q->start_html(-title=> 'Select Your School'), "Please select your school from the following list:", $q->start_form, $q->popup_menu( { -name => 'school_id', -values => [ sort keys %$namesref ], }), .....
# Sort by alpha sort keys %$namesref # Sort by alpha reverse order sort { $b cmp $a } keys %$namesref # Sort by numeric value sort { $a <=> $b } keys %$namesref # etc...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Sorting my hashref by value for printing a popup_menu using CGI
by jerrygarciuh (Curate) on Jan 14, 2004 at 00:11 UTC | |
by Roger (Parson) on Jan 14, 2004 at 00:45 UTC |