in reply to Sorting an array II
Try this (see the -values line):
popup_menu(-name=>"array", -values=>[sort {$array{$a} <=> $array{$b}} keys %array], -labels=>\%array, -default=>$array1, -class=>"formfield")
BTW, why did you name a hash "%array" ;-)?
Update: Here's a quick test:
use CGI qw/:standard/; my %array = (a => 2, b=>1, c=>3); print popup_menu(-name=>'test', -values=>[sort {$array{$a} <=> $array{$b}} keys %array], -labels=>\%array) __END__ <select name="test"> <option value="b">1</option> <option value="a">2</option> <option value="c">3</option> </select>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting an array II
by powerhouse (Friar) on Mar 03, 2003 at 19:07 UTC |