Hi I have a data structure which is of the following form:
$data = {
'a' => { key1 => 2, key2 => 1 },
'b' => { key1 => 1, key2 => 2 },
'c' => { key1 => 1, key2 => 1 },
'd' => { key1 => 3, key2 => 2 },
'e' => { key1 => 3, key2 => 1 },
'f' => { key1 => 1, key2 => 2 },
};
what I want to be able to do is loop through this data structure in ascending order of key2
, descending order of key1
, and then ascending order of the hash key, e.g:
e
a
c
d
b
f
how can I achieve this in perl? I know that I can sort the hash by key using sort keys %$data
, but how can I sort by multiple values and keys?