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


Groups > comp.lang.python > #65649

Re: Sorting dictionary by datetime value

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ikorot01@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.050
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'worked.': 0.09; '&gt;&gt;': 0.16; 'be:': 0.16; 'igor': 0.16; 'iterating': 0.16; 'tuple.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'email addr:gmail.com&gt;': 0.22; 'print': 0.22; '&gt;': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'that.': 0.31; 'keys': 0.31; 'probably': 0.32; 'url:python': 0.33; 'no,': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; "didn't": 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'url:mail': 0.40; 'you.': 0.62; '7:25': 0.84; 'actually,': 0.84; 'fail.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6yKMUvDWQ+II9xUutQWWHPDKzFgNZXXz63IGIs5bbYo=; b=sGzUkWAK33N5LnNJAyDPcbOnHJpnZfm8DH0WS9a6YnhBgtH50FUfIGFe9WKDTh+1wh z2LexpaL1vw0y9ZO0/8oHVoQlHQ8aHW9FhtdUY0YQMF3TAXzmxDcWXlFWEUh4pYJ0EYA oPY+7nhOZ7vUcrI+QxJwFz97eveL40Do/t9fJee82B5HiCEEzyEskCpKWj2tNLa3v2Po En7zF3U5GADR7IvAny2nDOvdnpeHSc1SeGOXuqyGBpIplcsNfcr47XsACctOtW2357A6 U0r1lUCP0dDvHsiUhMoV/5zzJJ2GkGDuGlfTmeUSyojU3vb0TM9zYIwFMO25sr5Nce9U 9BbQ==
MIME-Version 1.0
X-Received by 10.220.106.84 with SMTP id w20mr14236374vco.18.1391848528989; Sat, 08 Feb 2014 00:35:28 -0800 (PST)
In-Reply-To <CAPTjJmr83BOfsxpPL7m63S7ShJmo30B8e=Nv=+kVfOu_2bw1wQ@mail.gmail.com>
References <CA+FnnTxTvmSu922+Cg83jp8O_XdXXVnhQ1zaDEOd_41bONcoRQ@mail.gmail.com> <CAPTjJmqDusdFC1eLbU6LF5-up__LAE-63ii0UUvAGGNem9U4+w@mail.gmail.com> <CA+FnnTz8PLn=usNyotgC6fRKVsjL6DKt9PSd4Koudwvxi3BBcw@mail.gmail.com> <CAPTjJmq9b2gs_61X2uupV-CHtknu3Pna2BUu6C3zUrpHPZw08w@mail.gmail.com> <CA+FnnTwtrsADM2G2zRrGg7SBB5K8cEhnhaFc_n6QYomCGqUhQA@mail.gmail.com> <CA+FnnTxae8u3m+LS-KfkNwO22x3MRV7kvQgjhegWzTV9WshUzA@mail.gmail.com> <CAPTjJmr83BOfsxpPL7m63S7ShJmo30B8e=Nv=+kVfOu_2bw1wQ@mail.gmail.com>
Date Sat, 8 Feb 2014 00:35:28 -0800
Subject Re: Sorting dictionary by datetime value
From Igor Korot <ikorot01@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=047d7b3435c026d0fe04f1e0fd41
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6525.1391848537.18130.python-list@python.org> (permalink)
Lines 79
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391848537 news.xs4all.nl 2913 [2001:888:2000:d::a6]:37055
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65649

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Thank you. That worked.
And no, I didn't notice that change. :(


On Sat, Feb 8, 2014 at 12:29 AM, Chris Angelico <rosuav@gmail.com> wrote:

> On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot <ikorot01@gmail.com> wrote:
> >> Try this:
> >>
> >> sorted_items = sorted(my_dict.keys(), key=my_dict.get)
> >> for key in sorted_items:
> >>     print my_dict[key], key
> >
> >
> > This code fail.
> > sorted_item is a list of tuples. And so iterating the list in the for
> loop I
> > will get a tuple.
> > It probably should be:
> >
> > for key[1] in sorted_items:
> >
> > Let me try that.
> >
>
> Actually, it's a list of keys - notice that I changed my_dict.items()
> into my_dict.keys()?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: Sorting dictionary by datetime value Igor Korot <ikorot01@gmail.com> - 2014-02-08 00:35 -0800

csiph-web