Hi, I am trying to configure an efficient algorithm (faster than O(n^2)) for sorting and pairing elements between 2 arrays. However this needs to work under the premise that neither array's elements can be compared to other elements in their own array.
Edit: The elements of the arrays are "sizes" which correspond to particular objects. The idea is that two parts of the same size will fit together. If we were to call the parts screws and holes a screw will only fit in a hole of the same size. However we cannot compare holes to holes or screws to screws for the purpose of this algorithm.
So I am trying to find an algorithm that will best pair together these elements of screw and hole sizes and sort them without comparing an element to elements in the same array.
Re-edit: When two elements are compared from the array we are able to know whether the screw is bigger or smaller than the hole it is compared to.