Q:

Optimal algorithm to find maximum value of dot product of two lists

I am looking for an optimal (fastest) way to find a maximum value of dot product of two lists. A list can be rearranged freely in order to maximize the result.
My idea for this was to quicksort two lists and then simply calculate dot product of two sorted lists. 
Will this give me an optimal time complexity? Will it give the always correct result? 

A:

Yes, this is a correct algorithm.  (This is a consequence of the rearrangement inequality.)  Wikipedia pages suggest that quicksort has $O(n^2)$ worst-case running time, but in practice, usually better running time than $O(n\log n)$ algorithms.  The right choice here is beyond the scope of your question: it depends on your model of computation and your cost model and on the statistics of problem instances.

