this question comes together with another one i posted few hours ago:
Sorting dict items by key, beyond alphanumeric sorting
Keeping the need of having a tuple-like object ordered in that way https://stackoverflow.com/users/2141635/padraic-cunningham answered me very well,
now i need to modify tuple items, for example:
od = sorted(dizN.items(), key=key_func) #creates the sorted list of tuples
od[3][1]+=1 #is my attempt to increase by 1 the 2nd element of the 3rd tuple in the list of tuples; of course it is not possible.
Keep in mind which kind of object is "od":
od
Out[157]:
[('a0p12', 0),
('a1p11', 0),
('a2p10', 0),
('a3p9', 0),
('a4p8', 0),
('a5p7', 0),
('a6p6', 0),
('a7p5', 0),
('a8p4', 0),
('a9p3', 0),
('a10p2', 0),
('a11p1', 0),
('a12p0', 0)]
I think a good solution for this problem would be to transform this list of tuples to a list of lists of 2 elements; this is the output i'm thinking to:
[['a0p12', 0],
['a1p11', 0],
['a2p10', 0],
['a3p9', 0],
['a4p8', 0],
['a5p7', 0],
['a6p6', 0],
['a7p5', 0],
['a8p4', 0],
['a9p3', 0],
['a10p2', 0],
['a11p1', 0],
['a12p0', 0]]
Does anybody know how to do this? Thanks a lot to anyone will answer!