Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

( #463973=categorized answer: print w/ replies, xml ) Need Help??

Q&A > arrays > How to Test if Two Arrays are Ordered in the Same Way 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 ...

Comment on Answer: How to Test if Two Arrays are Ordered in the Same Way
Download Code
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 imbibing at the Monastery: (3)
As of 2016-02-14 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (459 votes), past polls