Sep 6, 2010, 9:40 AM
Post #1 of 4
Sort Multidimensional Hashes in Perl
I just joined this fourum today and I am happy to be among the experts and friends with different levels of programming.
I am rather new to perl programming so appology in advance if the question looks simplistic. I would apprecitae if you could propose a clear and understandable solution for my problem. Thanks in advance ...
Here is the problem :
Suppose we have multi-dim array :
# define a hash
my %hash = (
KEY1 => [Alice,50,40],
KEY2 => [John,62,80],
KEY3 => [Reza,40,90],
And we want to sort this hash to give us the results :
1. sort based on value1 (which is alphabetically)
2. sort based on value2 (which is numerically)
3. sort based on value3
Please provide me with your ideas.
Looking forward to hearing from you.