Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Answer: How to Test if Two Arrays are Ordered in the Same Way

by jdhedden (Deacon)
on Jun 06, 2005 at 16:23 UTC ( #463973=categorized answer: print w/replies, xml ) Need Help??

Q&A > arrays > How to Test if Two Arrays are Ordered in the Same Way - Answer contributed by jdhedden

Your decision line needs to be:
my $decision = grep($h{$$ar2[$_-1]} > $h{$$ar2[$_]}, 1..$#{$ar2}) +? 0 : 1;
You have to take into account the elements order with respect to each other. In this case, pos1 <= pos2 <= pos3 ...

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-10-19 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (255 votes). Check out past polls.

    Notices?