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 its operands to numeric.

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to