title: How to group similar items in a list using Haskell?
body: <p>Given a list of tuples like this: </p>
  
  <pre><code>dic = [(1,"aa"),(1,"cc"),(2,"aa"),(3,"ff"),(3,"gg"),(1,"bb")]
  </code></pre>
  
  <p>How to group items of <em>dic</em> resulting in a list <em>grp</em> where,</p>
  
  <pre><code>grp  = [(1,["aa","bb","cc"]), (2, ["aa"]), (3, ["ff","gg"])]
  </code></pre>
  
  <p>I'm actually a newcomer to Haskell...and seems to be falling in love with it..<br>
  Using <em>group</em> or <em>groupBy</em> in <em>Data.List</em> will only group similar adjacent items in a list.
  I wrote an inefficient function for this, but it results in memory failures as  I need to process a very large coded string list. Hope you would help me find a more efficient way.</p>