test_match_order <- function(x,y) {
if (all(x==y)) print('Perfect match in same order')
if (!all(x==y) && all(sort(x)==sort(y))) print('Perfect match in wrong order')
if (!all(x==y) && !all(sort(x)==sort(y))) print('No match')
}
test_match_order(x,y)
[1] "Perfect match in wrong order"
And here is another version based on my original comment above with an improvement from @alexis_laz below that makes the function more robust:
test_match_order2 <- function(x,y) {
if (isTRUE(all.equal(x,y))) print('Perfect match in same order')
if (!isTRUE(all.equal(x,y)) && isTRUE(all.equal(sort(x),sort(y)))) print('Perfect match in wrong order')
if (!isTRUE(all.equal(x,y)) && !isTRUE(all.equal(sort(x),sort(y)))) print('No match')
}