Compare two ranked lists of words

I have looked around and I'm not sure I've seen an appropriate answer though this questions is, I think, similar:

Comparison of ranked lists

it does not answer my question - which more succinctly would be:

'How similar are two ranked lists, and, if similar, is this similarity greater than that which would occur by chance?'

I have two ranked lists, for example two lists of the most popular animals as pets in two towns:

town 1 = [dog, cat, possum, fish, pig, degu]

town 2 = [dog, cat, degu, fish, cow, goat]

In both towns, dogs and cats are the first and second most popular pets respectively, but possums are more popular than degus in town 1.

How might I show the correlation between the preferences in both towns.

I believe I need to use a rank correlation but I am not sure what values to compare.

My understanding is that I should make a list of all animals:

total = [dog, cat, possum, fish, pig, degu, cow, goat]

and then convert the town lists:

town 1 = [1, 2, 3, 4, 5, 6]

town 2 = [1, 2, 6, 4, 7, 8]

and perform a Spearmans correlation on these values, but I'm not sure if that is an accurate method.

Let us denote your universe by $$\{1,...,8\}$$ according to your chosen order, i.e. {dog, cat, possum, fish, pig, degu, cow, goat}.

Because not all elements occur in both lists, we shall pretend non-occurring elements within any list are ranked tied lasts, that is, cows and goats are ranked equal $$7$$th in town $$n°1$$, and possum and pig are ranked equal $$7$$th in town $$n°2$$.

Now, the rank vectors are as follows: $$town\hspace{1mm} 1: 1,2,3,4,5,6,7,7$$ and $$town\hspace{1mm} 2:1,2,7,4,7,3,5,6.$$

Note that entry $$n°j$$ in each enumeration is the position of the $$j$$th element of the universe.

Spearman's rank correlation coefficient and Kendall tau distance reflect how similar two rankings are.

If you were using the programming language R, you would proceed as follows:

    town1 <- c(1,2,3,4,5,6,7,7)
town2 <- c(1,2,7,4,7,3,5,6)
data <- cbind(town1,town2)
cor(data,method="spearman") # 0.47
cor(data,method="kendall") # 0.37

# Testing whether correlation is significantly different from zero
# Null hypothesis: true correlation equals zero.
# Alternative hypothesis: true correlation is not equal to zero

cor.test(data[,1],data[,2],method="spearman") # approximate p-value = 0.24
cor.test(data[,1],data[,2],method="kendall") # approximate p-value = 0.21


In conclusion, we cannot reject the null hypothesis that the true correlations are equal to zero, i.e. the hypothesis that the rankings are similar just by chance.