Re: converting a hash to an array

2002-05-29 Thread Janek Schleicher
Felix Geerinckx wrote at Wed, 29 May 2002 17:17:38 +0200: > on Wed, 29 May 2002 16:10:40 GMT, [EMAIL PROTECTED] (Janek Schleicher) wrote: > >> Oops, there's a typo :-(( >> >> Of course, I meant >> @sorted = reverse sort { $myhash{$a} <=> $myhash{b} } keys %myhash; > > There's another typo. Ye

Re: converting a hash to an array

2002-05-29 Thread Peter Lemus
Please remove me from email list. thanks. --- Felix Geerinckx <[EMAIL PROTECTED]> wrote: > on Wed, 29 May 2002 12:58:33 GMT, > [EMAIL PROTECTED] (Craig > Hammer) wrote: > > > I thought this would work: > > Your code is very buggy: > > > > @sorted = sort { $myhash{$b} <=> $myhash{a} } keys

Re: converting a hash to an array

2002-05-29 Thread Felix Geerinckx
on Wed, 29 May 2002 16:10:40 GMT, [EMAIL PROTECTED] (Janek Schleicher) wrote: > Oops, there's a typo :-(( > > Of course, I meant > @sorted = reverse sort { $myhash{$a} <=> $myhash{b} } keys %myhash; There's another typo. And I'd rather add # sort keys in descending numerical order th

Re: converting a hash to an array

2002-05-29 Thread Janek Schleicher
Janek Schleicher wrote at Wed, 29 May 2002 17:20:02 +0200: > Make it more readable and write: > > @sorted = reverse sort { $myhash{$b} <=> $myhash{b} } keys %myhash; Oops, there's a typo :-(( Of course, I meant @sorted = reverse sort { $myhash{$a} <=> $my

Re: converting a hash to an array

2002-05-29 Thread David T-G
Janek, et al -- ...and then Janek Schleicher said... % % Craig Hammer wrote at Wed, 29 May 2002 14:58:33 +0200: % ... % > @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ; ... % % You want to sort decreasingly, from the highest to the lowest. ... % Make it more readable and write: %

Re: converting a hash to an array

2002-05-29 Thread Janek Schleicher
Craig Hammer wrote at Wed, 29 May 2002 14:58:33 +0200: > I've found a couple of examples of moving an array into a hash, but not of moving a >hash into an > array. > > I thought this would work: > > @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ; > I'd like to give another hint,

RE: converting a hash to an array

2002-05-29 Thread Craig Hammer
Thank you Felix and Bob. I see I was approaching this compeltely wrong. Craig Hammer -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 8:23 AM To: [EMAIL PROTECTED] Subject: Re: converting a hash to an array on Wed, 29 May 2002 12:58:33

Re: converting a hash to an array

2002-05-29 Thread Felix Geerinckx
on Wed, 29 May 2002 12:58:33 GMT, [EMAIL PROTECTED] (Craig Hammer) wrote: > I thought this would work: Your code is very buggy: > @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ; This should read: @sorted = sort { $myhash{$b} <=> $myhash{$a} } keys %myhash ;

RE: converting a hash to an array

2002-05-29 Thread Bob Showalter
> -Original Message- > From: Craig Hammer [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, May 29, 2002 5:59 AM > To: Perl (E-mail) > Subject: converting a hash to an array > > > I've found a couple of examples of moving an array into a > hash, but not

RE: converting a hash to an array

2002-05-29 Thread Craig Hammer
, Harry [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 8:05 AM To: '[EMAIL PROTECTED]' Subject: RE: converting a hash to an array > -Original Message- > From: Craig Hammer [mailto:[EMAIL PROTECTED]] > > @sorted = sort { $myhash{$b} <=&g

RE: converting a hash to an array

2002-05-29 Thread Jackson, Harry
> -Original Message- > From: Craig Hammer [mailto:[EMAIL PROTECTED]] > > @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ; ^ * COLT Telecommu

converting a hash to an array

2002-05-29 Thread Craig Hammer
I've found a couple of examples of moving an array into a hash, but not of moving a hash into an array. I thought this would work: @sorted = sort { $myhash{$b} <=> $myhash{a} } keys %myhash ; while ( <@sorted> ) { printf ( "first field = %s second field = %s\n", $sorted{1}, $sorted{2} ) ;