Suppose there are two arrays (They have the same length), I want to give a quantitative description about the similarity between them. I define a formula like this, which means we can shuffle them arbitrarily. If we use the stupidest method, i.e. calculate every possible result, we need to keep array B unchanged and keep shuffling array A. There should be $n!$ kinds of $\sum (A_i-B_j)^2$ . (Because there are $n!$ different orders for array A.)
But is there any fast algorithm for it? $$ \min_{\text{$\sigma$ permutation of $\{1,\dots,n\}$}} \sum_{1\le i\le n}(A_i-B_{\sigma(i)})^2 $$