Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Some very helpful thoughts there, thanks. I'll review the discussion a bit more yet...

The current application is only dealing with small arrays (maybe selecting 10-20 items at a time from an array of a 100-200 elements)... but I thought it was an interesting question in terms of determining a technique to use on larger arrays. It's akin to extracting a slice of an array BUT in this case, all the required elements are not contiguous, hence manipulating indexes would seem the zippier approach.

As it happens, the arrays are comprised of hash keys already... and the use of Tie::IxHash to try and preserve the insertion order into multi-key hashes isn't working the way I expect. For example, doing something like:-

push(@{$hash{$project}{$vitem}}, @list);

...and then 'traversing the hash' (say, using Data::Dumper) reveals the {$project} order is maintained but the order of {$vitem}s within each {$project} is not; hence, I need to work out another way.

Better I build-up some example data and include my code/input/output here than to try and explain further for now, methinks...

Again, thanks for the suggestions... More to follow later...

Edit: Replaced Tie::Hash with Tie:IxHash

In reply to Re: How to Order an Array's Elements to Match Another Array's Element Order by ozboomer
in thread How to Order an Array's Elements to Match Another Array's Element Order by ozboomer

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (5)
    As of 2019-11-12 08:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Strict and warnings: which comes first?



      Results (64 votes). Check out past polls.

      Notices?