Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30993
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.034 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'false.': 0.07; '9:13': 0.16; 'assigns': 0.16; 'discarded': 0.16; 'iteration': 0.16; 'iteration,': 0.16; 'list;': 0.16; 'oct': 0.16; 'sorting': 0.16; 'sorts': 0.16; 'subject: \n ': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'sort': 0.21; 'all,': 0.21; 'thanks.': 0.21; 'header:In-Reply- To:1': 0.25; 'instead.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'second,': 0.29; 'received:209.85.215.46': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'adds': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'list.': 0.35; 'method': 0.36; 'does': 0.37; 'item': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'step': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'first': 0.61; 'results': 0.65; 'overall': 0.66; 'subject:value': 0.84; 'to:name:python': 0.84; 'anywhere,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=TLIz4Ggae4ZsxLq5CW8l6fOPde4U1WD3vi1py/gn/IY=; b=huW3SXXp5/2s3o6u66IAS2ZDKoA+qw6qncSyz12Cm0A6ej8ryvMicpveKwL4lz9q/S k7nlu9840240R4qQ1SizCgQyRsnMA4xNZtHtSFcIW0R5P6DrwAljh2y8il9Tv8QKIedL YAPQ9NH01B++lhuButln8vwR5FHHXUlKpb1lWQLuPeXpJ0grt6bfsR7uNvJ40iipslk6 f4DjlfcDAjJbW04LAYBC1GdfxcHwjjK73y3b+SUsxUxBq2CChav5RhJXH8yyj0VXIEgB AquYwcoUUQ4qxKdqsa5kI4Y8mzjZOGbUMJ/yljypGiHZ2Al5pAVujNr1QOVykyL77Mz6 kzKQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <62e7500b-0d7d-4d5e-8c10-197d1988f364@googlegroups.com> |
| References | <2d6d84d4-0f70-4280-96e2-f9fe17d5be8b@googlegroups.com> <mailman.1928.1349632173.27098.python-list@python.org> <62e7500b-0d7d-4d5e-8c10-197d1988f364@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 8 Oct 2012 21:24:46 -0600 |
| Subject | Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 | <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.1980.1349753118.27098.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1349753118 news.xs4all.nl 6880 [2001:888:2000:d::a6]:35135 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:30993 |
Show key headers only | View raw
On Mon, Oct 8, 2012 at 9:13 PM, Token Type <typetoken@gmail.com> wrote: > yes, thanks all your tips. I did try sorted with itemgetter. However, the sorted results are same as follows whether I set reverse=True or reverse= False. Isn't it strange? Thanks. First of all, "sorted" does not sort the list in place as you seem to be expecting. It returns a new sorted list. Since your code does not store the return value of the sorted call anywhere, the sorted list is discarded and only the original list is kept. If you want to sort a list in place, use the list.sort method instead. Second, you're not sorting the overall list. On each iteration your code: 1) assigns a new empty list to list_simi; 2) processes one of the pairs; 3) adds the pair to the empty list; and 4) sorts the list. On the next iteration you then start all over again with a new empty list, and so when you get to the sorting step you're only sorting one item each time. You need to accumulate the list instead of wiping it out on each iteration, and only sort it after the loop has completed.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-07 09:15 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-07 18:49 +0100
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-08 20:13 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-08 21:24 -0600
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? alex23 <wuwei23@gmail.com> - 2012-10-08 20:31 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-08 21:16 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? alex23 <wuwei23@gmail.com> - 2012-10-08 22:44 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-09 09:00 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-08 20:13 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-08 20:23 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Token Type <typetoken@gmail.com> - 2012-10-08 20:23 -0700
Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value? Terry Reedy <tjreedy@udel.edu> - 2012-10-07 15:53 -0400
How to control the internet explorer? yujian <yujian4newsgroup@gmail.com> - 2012-10-08 11:02 +0800
Re: How to control the internet explorer? alex23 <wuwei23@gmail.com> - 2012-10-07 20:37 -0700
csiph-web