Please put "code" tags around source code and sample data, like this:

<code>
code or data here...
</code>

or like this:

<c>
code or data here...
</c>

When you preview your post, you'll find links to formatting tips for PM.

Now, as to your sample data: you didn't do what I asked. You posted one set of input, and a completely separate set of output. The two sets seem to have nothing in common apart from the formatting, and your closing comment doesn't make sense:

I was hoping that the number "A1-4100|A1" would be fairly close to the top of the "sorted" list as "A1-4100" is the parent for a ton of numbers, however, it appears at line 1705 (...)
Huh? Why would you care about the specific line number where a given record actually shows up in the output? All that matters is that all dependent records come after it.

If that is not the case for a given run, create a small subset of the data to serve as a test set, run that through the script, and if you can show that the ordering is incorrect, post just that (hopefully small) minimal set of records that demonstrate the error.

Note that the actual ordering of output from my original code should be: the first top-level parent, then all records dependent on that, then the next top-level parent, then all records dependent on that, and so on.

(Update: note that the notion of "first top-level parent" is arbitrary; the "keys" function returens hash keys in essentially random order, so if you want to see top-level parents handled in a specific order, you'll need to sort them before they go into the grep function.)


In reply to Re^5: Perl modules or standard tools for searching hierachical data by graff
in thread Perl modules or standard tools for searching hierachical data by SlackBladder

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.