On Tue, 23 Jul 2002, dan wrote:

> ok.. that worked, now how about if i wanted it to go the other way.. from
> most to least?

foreach my $MyId (sort {$usernum{$a} <=> $usernum{$b}} keys (%usernum)) {
    print "$MyId\n";
}
This will print
server.two.com
server.four.com
server.three.com
server.one.com

Change $usernum{$a} <=> $usernum{$b} the other way around to reverse
the order

> 
> dan
> 
> "David Wagner" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Here is one shot:
> >
> >
> > %usernum = ( "server.one.com", "15",
> > "server.two.com", "5",
> > "server.three.com", "14",
> > "server.four.com", "9" );
> >
> > foreach my $MyId (sort {$a->[1] <=>$b->[1]} map{[$_,$usernum{$_}]} keys
> > %usernum) {
> >    printf "%-s\n", $MyId->[0];
> >  }
> >
> > Output:
> > server.two.com
> > server.four.com
> > server.three.com
> > server.one.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to