# coding: utf8 #
from itertools import groupby
d = [ [1 , 'test1'] , [2 , 'text2'] , [1 , 'tut text'] , [2 , 'text text'] , [3 , 'other text'] ]
for k,g in groupby(d, lambda x:x[0]):
print k,
for j in g:
print j,
print ''
# coding: utf8 #
from itertools import groupby
d = [ [1 , 'test1'] , [2 , 'text2'] , [1 , 'tut text'] , [2 , 'text text'] , [3 , 'other text'] ]
for k,g in groupby(d, lambda x:x[0]):
print k,
for j in g:
print j,
print ''
# coding: utf8 #
from itertools import groupby
d = [ [1 , 'test1'] , [2 , 'text2'] , [1 , 'tut text'] , [2 , 'text text'] , [3 , 'other text'] ]
for k,g in groupby(sorted(d), key = lambda x:x[0]):
print k,
for j in g:
print j,
print ''