XP is just a number | |
PerlMonks |
Re: How to Order an Array's Elements to Match Another Array's Element Orderby ozboomer (Friar) |
on Sep 17, 2019 at 11:43 UTC ( [id://11106292]=note: 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:-
...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 Section
Seekers of Perl Wisdom
|
|