title: How to merge two lists of tuples?
body: <p>I have two lists in Scala, how to merge them such that the tuples are grouped together?</p>
  
  <p>Is there an existing Scala list API which can do this or need I do it by myself?</p>
  
  <p>Input:</p>
  
  <pre><code> List((a,4), (b,1), (c,1), (d,1))
   List((a,1), (b,1), (c,1))
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>List((a,5),(b,2),(c,2),(d,1))
  </code></pre>