in reply to sort HoH by second level values in specific order
All that you need here is a sort-compare subroutine. The sort verb allows you to pass a subroutine-reference as an argument, and this subroutine when called will "magically" find itself presented with two variables: $a and $b. Only it needs to know what to do with them – only it needs to know if they, in fact, represent multi-level hashes: its only duty is to return a value that is less than, equal to, or greater than zero in each and every case. I therefore suggest that you define a separate sub for this purpose, and that you should carefully desk-check it in advance against a number of different hand-built test-case HOH values.