Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15301
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Dictionary sorting |
| Date | 2011-11-03 18:57 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <j8uo6n$gu6$1@reader1.panix.com> (permalink) |
| References | <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> |
In <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> Scott Ware <scottdware@gmail.com> writes:
> Python newbie here. So, when creating dictionaries, I am noticing that
> each time I print it out, that its not in the same order as when I typed
> it in. They seem to be getting sorted somehow. Is there a way to not sort
> them and leave the order as is?
Dictionaries don't maintain the order of the items.
If you want to keep track of the order in which the items were inserted,
you'll need to do that yourself using a separate mechanism (a list, for
example.)
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dictionary sorting Scott Ware <scottdware@gmail.com> - 2011-11-03 11:46 -0700
Re: Dictionary sorting John Gordon <gordon@panix.com> - 2011-11-03 18:57 +0000
Re: Dictionary sorting Scott Ware <scottdware@gmail.com> - 2011-11-03 12:00 -0700
Re: Dictionary sorting Chris Kaynor <ckaynor@zindagigames.com> - 2011-11-03 12:13 -0700
Re: Dictionary sorting insomnia@gmail.com - 2011-11-03 13:01 -0700
Re: Dictionary sorting Terry Reedy <tjreedy@udel.edu> - 2011-11-03 17:36 -0400
Re: Dictionary sorting Tim Chase <python.list@tim.thechases.com> - 2011-11-03 18:01 -0500
Re: Dictionary sorting Ben Finney <ben+python@benfinney.id.au> - 2011-11-04 11:06 +1100
Re: Dictionary sorting Hrvoje Niksic <hniksic@xemacs.org> - 2011-11-04 11:20 +0100
Re: Dictionary sorting Ben Finney <ben+python@benfinney.id.au> - 2011-11-04 23:19 +1100
Re: Dictionary sorting Chris Angelico <rosuav@gmail.com> - 2011-11-04 10:59 +1100
csiph-web