perl array of array of hashes sorting

Posted by srk on Stack Overflow See other posts from Stack Overflow or by srk
Published on 2010-03-24T18:16:47Z Indexed on 2010/03/24 18:23 UTC
Read the original article Hit count: 346

Filed under:
|
|
|
@aoaoh;

$aoaoh[0][0]{21} = 31;

$aoaoh[0][0]{22} = 31;

$aoaoh[0][0]{23} = 17;

for $k(0.. $#aoaoh) {

for $i(0.. $#aoaoh) {

for $val (keys %{$aoaoh[$i][$k]}) {

print "$val=$aoaoh[$i][$k]{$val}";

print "\n";
}}
}

output is

22=31

21=31

23=17

but i expect it to be

21=31

22=31

23=17

Please tell me where is this wrong.. Also how do i sort the values so that i get the output as

23=17

22=31

21=31 (if 2 keys have same value then key with higher value come first)

© Stack Overflow or respective owner

Related posts about perl

Related posts about arrays