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...