thanks rob. it worked
From: Rob Dixon
To: beginners@perl.org
Cc: Irfan Sayed
Sent: Thursday, June 23, 2011 3:37 PM
Subject: Re: sort hash
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue is , in hash,
On Jun 22, 12:49 pm, rco...@gmail.com (Rob Coops) wrote:
> On Wed, Jun 22, 2011 at 6:44 PM, josanabr wrote:
> ...
> Lets dissect this a little:
>
> Lets take the inner most thing ($var2) this is obviously a scalar (or a
> reference to another variable (I'll explain why I am betting it is a scalar
On 2011-06-23 11:36, Irfan Sayed wrote:
[I need to sort a hash, but my keys are integers]
Realize that all hash keys are strings.
sort { $hash_fin{$b} <=> $hash_fin{$a} } keys %hash_fin
You were almost there:
sort { $b <=> $a } keys %hash_fin
The <=> operator is numeric, so casts it
On 23/06/2011 10:36, Irfan Sayed wrote:
> Hi,
>
> i need to sort hash in descending order.
> but the issue is , in hash, i have key as integer value and the value
> associated with that key is string
>
> so when i do sort it does not really sort the hash on the key level
>
>
> i used follwoing
Hi,
i need to sort hash in descending order.
but the issue is , in hash, i have key as integer value and the value
associated with that key is string
so when i do sort it does not really sort the hash on the key level
i used follwoing code
foreach my $key (sort { $hash_fin{$b} <=> $hash_fi
On Thu, Jun 23, 2011 at 6:32 AM, Bryan R Harris
wrote:
>
>
> I much prefer perl to python given my recent forays into that language
> (python's regex is awful!), however it has an excellent plotting package
> that is very similar to matlab but supports things like marker alphas. It's
> called mat