Demo entry 6347073

OrderedDict

   

Submitted by anonymous on Feb 13, 2017 at 16:33
Language: Python 3. Code size: 203 Bytes.

from collections import OrderedDict
L= [[10, 'c'], [10, 'b'], [20, 'a.']]
D = OrderedDict()

for k, v in L:
     current_value = D.get(k, [])
     current_value.append(v)
     D[k] = current_value

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).