Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47542

Re: Sorting a set works, sorting a dictionary fails ?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
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 <saig8a-b3b.ln1@satorlaser.homedns.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 01:04 -0700
  Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 01:16 -0700
    Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 01:18 -0700
      Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 01:29 -0700
        Re: Sorting a set works, sorting a dictionary fails ? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-10 10:27 +0100
          Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 02:32 -0700
            Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 02:48 -0700
              Re: Sorting a set works, sorting a dictionary fails ? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-10 11:13 +0100
              Re: Sorting a set works, sorting a dictionary fails ? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-06-10 15:11 +0200
        Re: Sorting a set works, sorting a dictionary fails ? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-06-10 11:40 +0200
          Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 03:20 -0700
          Re: Sorting a set works, sorting a dictionary fails ? Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 03:42 -0700
            Re: Sorting a set works, sorting a dictionary fails ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-10 11:47 +0000
            Re: Sorting a set works, sorting a dictionary fails ? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-11 02:14 +0000
        Re: Sorting a set works, sorting a dictionary fails ? Larry Hudson <orgnut@yahoo.com> - 2013-06-11 02:16 -0700
  Re: Sorting a set works, sorting a dictionary fails ? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-06-10 11:19 +0200

csiph-web