9 posts
elena (Liu_Xiang) wrote:
I have a dictionary. {key: value, key2: value2}, Dict = {(4, 5): (2.733), (5, 2): (2.4533), (6, 2): (4.533), (7, 3): (1.333)}.
How could I reorder the key part to NewDict = {(0, 1): (2.733), (0, 2): (2.4533), (1, 0): (4.533), (1, 1): (1.333)}
This is what I do. But it does't reordered the number as I want.
Imax = Max(Dict.keys()[0])
jmax = Max(max.keys()[1])
values= Dict.value()
for m in range(Imax ):for k in range(jmax ):
NewDict [(k,m)] = values[m]