code: def min_scalar_prod(x, y):
      
      x = sorted(x)  # make copies
      y = sorted(y)  # to save arguments
      return sum(x[i] * y[-i - 1] for i in range(len(x)))
docs: Permute vector to minimize scalar product
  
      :param x:
      :param y: x, y are vectors of same size
      :returns: min sum x[i] * y[sigma[i]] over all permutations sigma
      :complexity: O(n log n)