dictionary = {(1,1):[(2,2),[(3,3),(4,4)],5]}
dictionary[(2,2)] = [(3,3),[(4,4),(5,5)],6]
dictionary[(3,3)] = [(4,4),[(5,5),(6,6)],7]
print dictionary
上面的代码将输出显示为:
{(3, 3): [(4, 4), [(5, 5), (6, 6)], 7], (1, 1): [(2, 2), [(3, 3), (4, 4)], 5], (2, 2): [(3, 3), [(4, 4), (5, 5)], 6]}
但是,我希望输出顺序为输入,即
{(1,1):[(2,2),[(3,3),(4,4)],5],(2,2):[(3,3),[(4,4),(5,5)],6],(3,3):[(4,4),[(5,5),(6,6)],7]}
如何重新排列字典?
答案 0 :(得分:1)
您需要使用有序字典而不是普通字典,如下所示:
function func3(p) {
console.log('p: ' + p);
}
func3("test");