in reply to how do i sort values of a hash of hash

The Camel has a discussion of sorting a hash by values rather than the keys. You use the optional expression block in the sort function.

@sortedkeys = sort { $hash{$a} <=> $hash{$b} } keys %hash;

Good luck.

Extrapolate the above to what you need...