How to group consecutive elements values based on the key value in python 3? : I'm a python beginner and need help on this.

My input is 
input: [(5, 1), (0, 3), (1, 3), (2, 3), (3, 3), (4, 3), (6, 3)]

input contains [(value,key)]

My output should be 

0,1,2

3,4,6

5

The consecutive values need be grouped based on the key count and then sorted to show the final output ..

ie) 5 appears once and should be grouped alone

0, 1, 2 has the key count as 3 and hence should be grouped together

3,4,6 has the key count as 3 and hence should be grouped together

The final output should be in sorted order and look like this

0,1,2

3,4,6

5

I tried with grouby itertools and it only groups the values based on similar keys. 

Any solutions would be helpful.