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, you didn't ask for.
You want to sort decreasingly, from the highest to the lowest.
But to find it out, one's need good eyes.
Especially when you read the code quickly,
you read sort the keys in myhash numerically.
The important information of the sort order is not simple to see.

Make it more readable and write:

@sorted = reverse sort { $myhash{$b} <=> $myhash{b} } keys %myhash;


Cheerio,
Janek

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

Reply via email to