I'm not sure I understand your goal. You seem to be printing a sequence of structured "paragraphs", like:
Report on remote host: (some.host) pid: (some pid) some socket statistics some more socket statistics ... pid: (some other pid) still more socket statistics had enough socket statistics? ... Report on remote host: (another.host) pid: (yet another pid) ... ...
Now, are you supposed to be sorting according to the "cnt" value within each "pid" paragraph? Or are you supposed to sort the pid paragraphs within a given "rip" section according to which pid has the highest "cnt" value? Or are you supposed to sort the "Remote host" sections according to which one has the highest "cnt" value?

Or maybe you don't really want the output to be structured that way? If you want each "rip/pid/socktype" ordered according to its respective "cnt" value (that is, it's okay that various lines for "rip X" are interleaved with lines for "rip Y" because of their "cnt" rankings), then you just come up with a suitable report line format that keeps all the information together on each line, use your loop to "sprintf()" each report line onto an array, then sort the array before you print it.

Once you clarify what you're trying to do, the answer should come pretty quickly.

(updated to fix grammar)


In reply to Re: Trouble sorting a nested HOH by graff
in thread Trouble sorting a nested HOH by mielstogo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.