Shouldn't that be "values %hash" for sorting the values (see below),
also be aware that a hash has no order like an array so you just have to
do what you want while in the foreach loop (or stick them into an
array).

  my %hash;
  foreach(sort {$hash{$a} <=> $hash{$b} } values %hash) {
    ....
  }


>>> "Shawn" <[EMAIL PROTECTED]> 06/24/02 07:49am >>>
Hello Pat,
  You can do it like so:

  my %hash;
  foreach(sort {$hash{$a} <=> $hash{$b} } keys %hash) {
    ....
  }

Shawn

----- Original Message ----- 
From: "Postman Pat" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 24, 2002 1:46 AM
Subject: sorting a hash by value.


> Greetings,
> I would like to sort a hash by value. The hash values are numbers. I
would 
> like to sort this by desceding order. How would I do this? I have
searched 
> and found nothing on it. I have found lots on sorting by key
though... 
> Please help dudes!
> 
> Ciao
> 
> LK
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
> 
> 
> 


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



ITM Business Solutions
Unit 4
Nine Trees Trading Estate
Morthen Road
Rotherham
S66 9JG

Reception
Tel: 01709 703288
Fax: 01709 701549

Help Desk
Tel:01709 530424
Fax: 01709 702159

CONFIDENTIALITY NOTICE: This message is intended only for the use of
the individual or entity to which it is addressed, and may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.



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

Reply via email to