Path: csiph.com!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ulrich Eckhardt Newsgroups: comp.lang.python Subject: Re: Sorting a set works, sorting a dictionary fails ? Date: Mon, 10 Jun 2013 11:19:55 +0200 Lines: 24 Message-ID: References: <3b252a10-a7e3-40f5-99dc-8afcf72cf997@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 74JMJEQRhD22+nGRLrFceAThsJX9Rd2gHe7o6Cx37nDw== X-Orig-Path: satorlaser.homedns.org!not-for-mail User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <3b252a10-a7e3-40f5-99dc-8afcf72cf997@googlegroups.com> Xref: csiph.com comp.lang.python:47542 Am 10.06.2013 10:04, schrieb Νικόλαος Κούρας: > months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 'Μάϊος':5, 'Ιούνιος':6, \ > 'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 'Νοέμβριος':11, 'Δεκέμβριος':12 } > > for key in sorted( months.keys() ): > ================ > > I'm having trouble ordering a dictionary though. I can't find a problem here. I tried simple dictionaries containing numbers as keys using Python 3.3, and sorting the keys works without any problem there. What exactly is the "trouble" you are having? Be a bit more precise and describe what you saw and, just in case, also what you expected to see. BTW: You have a line continuation there using a backslash. This isn't necessary, since the pair of {} automatically tell Python the target range. Good luck! Uli