title: Python group by
body: <p>Assume that I have a set of data pair where <em>index 0</em> is the value and <em>index 1</em> is the type:</p>
  <pre><code>input = [
            ('11013331', 'KAT'), 
            ('9085267',  'NOT'), 
            ('5238761',  'ETH'), 
            ('5349618',  'ETH'), 
            ('11788544', 'NOT'), 
            ('962142',   'ETH'), 
            ('7795297',  'ETH'), 
            ('7341464',  'ETH'), 
            ('9843236',  'KAT'), 
            ('5594916',  'ETH'), 
            ('1550003',  'ETH')
          ]
  </code></pre>
  <p>I want to group them by their type (by the 1st indexed string) as such:</p>
  <pre><code>result = [ 
             { 
               'type': 'KAT', 
               'items': ['11013331', '9843236'] 
             },
             {
               'type': 'NOT', 
               'items': ['9085267', '11788544'] 
             },
             {
               'type': 'ETH', 
               'items': ['5238761', '962142', '7795297', '7341464', '5594916', '1550003'] 
             }
           ] 
  </code></pre>
  <p>How can I achieve this in an efficient way?</p>