I have a set of data in the form:
X1 = [(1,1),(3,1),(5,0),(3,0),(2,1)]
I can't figure out how to group them such that:
X2 = [[(1,1),(3,1)],[(5,0),(3,0)],[(2,1)]]
i.e. they are grouped in a consecutive fashion by the second value in each tuple.
I know it's something with this:
http://docs.python.org/2/library/itertools.html#itertools.groupby