Ordering numbers

Fredrik Lundh fredrik at pythonware.com
Tue Jan 17 19:05:03 EST 2006

"yawgmoth7" wrote:

> I have a dictonary here:
> seq = {8:0x13AC9741, 10:0x27592E8, 4:0x4EB25D, 5:0x9D64B, 7:0x13AC9,
> 1:0x2759, 11:0x4EB, 3:0x9D, 9:0x13, 2:0x2, 0:0x0, 6:0x0}
> Python always prints them in order, from least to greatest.

nope.  Python prints them in

    ... in an arbitrary order which is non-random, varies across
    Python implementations, and depends on the dictionary's
    history of insertions and deletions.

    http://docs.python.org/lib/typesmapping.html (note 3)

> But I wanna have it show them in hte order that I put in. Thanks
> for all your help

to do that, you need to keep track of the order in a separate
data structure (a list works well for this purpose).


More information about the Python-list mailing list