Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15307
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'newbie': 0.03; 'cpython': 0.05; 'received:verizon.net': 0.07; 'terry': 0.07; 'typed': 0.07; 'python': 0.08; 'dict': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'entries': 0.15; 'iterates': 0.16; 'reedy': 0.16; 'somehow.': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'is?': 0.21; 'items.': 0.23; 'header:In-Reply- To:1': 0.23; 'creating': 0.25; '(and': 0.28; 'depends': 0.28; 'print': 0.29; 'seem': 0.30; 'hash': 0.30; 'pm,': 0.31; 'sort': 0.32; 'to:addr:python-list': 0.32; 'there': 0.33; 'header:User- Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; '(as': 0.34; 'all.': 0.34; 'depend': 0.36; 'entry': 0.37; 'received:org': 0.37; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'getting': 0.40; 'far': 0.40; 'being': 0.40; 'user': 0.40; 'order': 0.62; 'view': 0.65; 'here.': 0.66; 'order,': 0.73; 'ware': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Dictionary sorting |
| Date | Thu, 03 Nov 2011 17:36:25 -0400 |
| References | <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-74-109-121-73.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 |
| In-Reply-To | <16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2414.1320356213.27778.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1320356213 news.xs4all.nl 6850 [2001:888:2000:d::a6]:52795 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:15307 |
Show key headers only | View raw
On 11/3/2011 2:46 PM, Scott Ware wrote: > 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. No, the entries are not being sorted at all. > Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. If you want to keep the dict sorted by entry order (as far as the user view goes), use collections.OrderedDict. -- Terry Jan Reedy
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