Oh I am sorry that I did not make the problem more clear.
Suppose I have an array a = {2,1,3}
also suppose I have an array b = {1,2,3}.
So now, I want to check if some ordering of array b matches with array a.
The sequence of elements of array b can be:
{1,2,3},{2,1,3},{3,1,2},{3,2,1}...and...