title: What is an efficient way to match n items with corresponding n items
body: <p>Consider a set A of n bottles and set B of n caps, such that each bottle in A has unique cap in B.
  But bottle in A and caps in B all look the same. The only comparison that can be made is pair (a,b) of a bottle in A and a cap in B and test whether the threads of a are smaller, larger or perfect with threads of b.</p>
  
  <p>Give an efficient algorithm to match up all bottles with their caps.</p>
  
  <p>PS: This seems like I haven't done anything to get the solution, belive me, I did. Please just give me an answer.</p>