Re: sorting a hash alphabetically

2002-05-19 Thread Jolinar of Malkshur
See? I knew someone else would know a better way. Jolinar "Beau E. Cox" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi - you suggested: > > > foreach $lastname (sort { $a cmp $b } keys %names) { > > print "$lastname, $names{$lastname}\n"; > > } > > That

RE: sorting a hash alphabetically

2002-05-19 Thread Beau E. Cox
Hi - you suggested: > foreach $lastname (sort { $a cmp $b } keys %names) { > print "$lastname, $names{$lastname}\n"; > } That works well. I'm lazy, so I usually do something like: print "$_, $names{$_}\n" for (sort keys %names); 1) for == foreach so save 4 keystrokes. 2) I use the for ..

Re: sorting a hash alphabetically

2002-05-19 Thread Jolinar of Malkshur
This is what I've been using and it seems to work well: foreach $lastname (sort { $a cmp $b } keys %names) { print "$lastname, $names{$lastname}\n"; } I'm pretty new to Perl, though, and someone else might know a better way. Jolinar "Jerry Preston" <[EMAIL PROTECTED]> wrote in message [EMAIL

sorting a hash alphabetically

2002-05-17 Thread Jerry Preston
Hi! I have a hash built in the following way: $names{ $ID } = $your_name; I want to l want to list in print $query->popup_menu( -name=>'Emp', -values=> \%who, -default=> \%who, ); but in alphabetically. How