perl sorting an array of hashes

Posted by srk on Super User See other posts from Super User or by srk
Published on 2010-03-24T19:36:40Z Indexed on 2010/03/24 19:43 UTC
Read the original article Hit count: 518

Filed under:
|
|
|
use strict;
my @arr;
$arr[0][0]{5} = 16;
$arr[0][1]{6} = 11;
$arr[0][2]{7} = 25;
$arr[0][3]{8} = 31;
$arr[0][4]{9} = 16;
$arr[0][5]{10} = 17;

sort the array based on hash values so this should change to

$arr[0][0]{6} = 11;
$arr[0][1]{9} = 16;
$arr[0][2]{5} = 16;
$arr[0][3]{10} = 17;
$arr[0][4]{7} = 25;
$arr[0][5]{8} = 31;

first sort on values in the hash.. when the values are same reverse sort based on keys... Please tell me how to do this..

Thank you

© Super User or respective owner

Related posts about perl

Related posts about array