title: Finding common elements of a list based on some criteria?
body: <p>The input is in form of a list of tuples, </p>
  
  <pre><code>left_corners = [((380, 456), 1), ((1129, 456), 2), ((354, 328), 3), ((1137, 325), 4)]
  right_corners = [((784, 456), 1), ((1535, 456), 2), ((778, 328), 3)]
  </code></pre>
  
  <p>The common elements would be the ones which have the second element of the tuple as <code>1, 2, 3</code> so I would want the final representation to look like - </p>
  
  <pre><code>[(((380, 456), 1),((784, 456), 1)), (((1129, 456), 2),((1535, 456), 2)), (((354, 328), 3), ((778, 328), 3))]
  </code></pre>
  
  <p>I can't think of a solution without a few loops (looping over both the elements and appending the elements which have the same second element in a common list). Is there a more pythonic way? I am open to other representations of this in numpy or something too.</p>
  
  <p><strong>Assumptions:</strong> 
  We can assume both lists are sorted with the key being the second element of the list, but either <code>left_corners</code> or <code>right_corners</code> might have more elements than the other</p>