I have two lists in Python.
list1 = ['a','a','b','a','c','b','c','a','d','a','b']
list2 = ['1','2','21','12','1','32','11','12','21','3','31']
I have to group the similar elements in list1. The corresponding elements in list2 should also get grouped based on this. Output should be this:
list1 = [['a','a','a','a','a'],['b','b','b'],['c','c'],['d']]
list2 = [['1','2','12','12','3'],['21','32','31'],['1','11'],['21']]
What is the best way to do this?