I have a dictionary with tuple as its key, like:
d={('w1','u1'):3,('w1','u2'):8,('w2','u1'):1,('w1','u3'):11,('w2','u3'):6}
Now I want to gather all items for each 'w', i.e. the first element in the keys:
'w1' : ('w1','u1'):3 ('w1','u2'):8 ('w1','u3'):11 -------
'w2' : ('w2','u1'):1 ('w2','u3'):6
then sort each row by the values to get:
'w1' : 'u3':11 'u2':8 'u1':3 -------
'w2' : 'u3':6 'u1':1
Can anybody give me some hint to do it? Thanks