Here is one possibility. Note that rankings are permutations, so searching for that term might be useful.
First, select a notion of "approaching" between rankings/permutations, i.e., select a distance between two permutations. For instance, you could use the minimum number of transpositions to change one permutation to the other, or the minimum number of transpositions of adjacent elements. Note that these are different notions of distance. (You can of course let your choice be guided by what distance between permutations is implemented in your software of choice.)
Calculate the distance between the true ranking, and your provided ranking.
Now, simulate many possible rankings, i.e., pick many random permutations. In your specific case, there are only 24 possible permutations, so you could go over them exhaustively, but for larger sizes, this quickly becomes infeasible.
For each random permutation, calculate and store its distance to the true ranking.
To obtain a p-value against the null hypothesis that your provided ranking is closer to the true ranking than might be expected by chance, check how many of the randomized distances are smaller than the distance of your provided ranking.
R code:
library(CEGO)
true_ranking <- c(2,3,4,1)
provided_ranking <- c(2,3,1,4)
provided_distance <- distancePermutationSwap(provided_ranking,true_ranking)
n_sims <- 1000
distances <- rep(NA,n_sims)
for ( ii in 1:n_sims ) {
set.seed(ii) # for reproducibility
perm <- sample(seq_along(true_ranking),length(true_ranking))
distances[ii] <- distancePermutationSwap(perm,true_ranking)
}
ecdf(distances)(provided_distance) # p-value
dd <- min(diff(as.numeric(names(table(distances)))))
hist(distances,breaks=seq(-dd/2,1+dd/2,by=dd))
abline(v=provided_distance,col="red",lwd=2)