Ordering in the printout of a dictionary

Mok-Kong Shen mok-kong.shen at t-online.de
Tue Mar 18 01:32:05 CET 2014


Could someone kindly explain a phenomenon in the following where:

(1) I first typed in a dictionary but got a printout in a reordered
form.

(2) I then typed in the reordered form but got a printout in the
order that I typed in originally in (1).

That is, there is no stable "standard" ordering. Why is that so?

Is there a way to force a certain ordering of the printout or else
somehow manage to get at least a certain stable ordering of the
printout (i.e. input and output are identical)?

Thanks in advance.

M. K. Shen
------------------------------------------

 >>> {'label': 3, 'parent': 0, 'left child': 1, 'right child': 2}
{'right child': 2, 'parent': 0, 'left child': 1, 'label': 3}
 >>> {'right child': 2, 'parent': 0, 'left child': 1, 'label': 3}
{'label': 3, 'parent': 0, 'left child': 1, 'right child': 2}



More information about the Python-list mailing list