|Problems? Is your data what you think it is?|
How to Order an Array's Elements to Match Another Array's Element Orderby ozboomer (Friar)
|on Sep 17, 2019 at 07:13 UTC||Need Help??|
ozboomer has asked for the wisdom of the Perl Monks concerning the following question:
I'm doing some (what I think is) more unusual things with some arrays.. and I'm looking to see if there's a more 'elegant' method than what I'm currently using...
I have a 'reference' array that is processed, producing a 'subset' array. Generally, the elements of the 'subset' array are not in the same order as they appear in the 'reference' array... but that's the order I need to do some more processing.
So, I've cobbled together some code that does the job, viz:-
...but maybe there's a better way to do it, say, using grep in conjunction with map but I can't vizualize how that might be done -- I'm still not super flash with the 'more clever' ways of using these functions(!)
I would search for something to help me out... but I don't even know how to describe what I'm trying to do(!)
I'd appreciate any suggestions on where to go next...