Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35562
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joshua.landau.ws@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'exception': 0.03; 'bug.': 0.07; 'table.': 0.07; 'undefined': 0.07; 'missed': 0.09; 'python': 0.09; 'shame': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '(but': 0.15; '(11': 0.16; 'humour': 0.16; 'int.': 0.16; 'least,': 0.16; 'naming': 0.16; 'wrote:': 0.17; 'comparing': 0.17; "shouldn't": 0.17; 'input': 0.18; 'code.': 0.20; 'sort': 0.21; "i'd": 0.22; '>': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'leave': 0.26; 'cc:addr:gmail.com': 0.27; 'coding': 0.27; 'message-id:@mail.gmail.com': 0.27; 'post': 0.28; 'crash': 0.29; 'scheme.': 0.29; 'character': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'december': 0.32; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'really': 0.36; "didn't": 0.36; 'enough': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'first': 0.61; 'thomas': 0.62; 'skip:n 10': 0.63; 'more': 0.63; 'gave': 0.65; 'compact,': 0.84; 'here!': 0.84; '\xa0at': 0.84; 'approach.': 0.91; 'angel': 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 :cc:content-type; bh=x99HplAC+FThghKlACp8FcWWEdCVLZitGViAi0Z5jPU=; b=fJ5mlabzaUP8d7+N6Ve6CDJLMkEgudXj3CQ9SH0RWlvAz5Upvz6Lhbn7NDsgivn9RC fs0VhBQqC+tYFsu4RqIugGZDg32XwPdU2glBEOmU2QHpxnTtj8UDH2pUoRTunX3bcCCv fB8+NZG7h7rDtXg0AMu4c8iY2AFHPul3tUwZx9Of9Exs2OkNHkwu0to6dEDruOP1gykW gx/ri2otKehRS+ww/IEsN99Lgr4WZF0i3luPbyQ1JMf6ir1witIJR52fo4Qz+mj7JZX9 NFFWREwCLvcUj4jPLDO2aCbn/rn94NCdaoKumfqVGg45+JDYsVsCh9tLkv6vGqabTToY I00w== |
| MIME-Version | 1.0 |
| In-Reply-To | <50D9453D.3090907@davea.name> |
| References | <roy-BEEA73.11183724122012@news.panix.com> <mailman.1262.1356372812.29569.python-list@python.org> <945054f8-9827-4aaf-9c4d-00970404ca18@googlegroups.com> <50D9453D.3090907@davea.name> |
| From | Joshua Landau <joshua.landau.ws@gmail.com> |
| Date | Thu, 27 Dec 2012 01:13:11 +0000 |
| Subject | Re: Custom alphabetical sort |
| To | d@davea.name |
| Content-Type | multipart/alternative; boundary=047d7b6226768335c904d1cb42bd |
| Cc | python-list <python-list@python.org>, pander.musubi@gmail.com |
| 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.1313.1356570839.29569.python-list@python.org> (permalink) |
| Lines | 122 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356570839 news.xs4all.nl 6913 [2001:888:2000:d::a6]:53816 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35562 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 25 December 2012 06:18, Dave Angel <d@davea.name> wrote:
> On 12/24/2012 06:19 PM, Pander Musubi wrote:
<snip>
> > Thanks very much for this efficient code.
>
> Perhaps you missed Ian Kelly's correction of Thomas Bach's approach:
>
> d = { k: v for v, k in enumerate(cs) }
>
>
> def collate(x):
> return list(map(d.get, x))
>
> sorted(data, key=collate)
>
> I'd use Ian Kelly's approach.
Well, he was first to it :P
> It's not only more compact,
I take offence* here! The only difference was "list(map(d.get, x))" vs
"[hashindex[s] for s in string]" (11 chars) and my longer naming scheme. If
you really care enough about those to sway your judgement, shame on you! ;)
* Not really
it shouldn't
> give an exception for a character not in the table.
That was a choice, not a bug. I didn't want undefined behaviour, so I
thought I'd leave it to crash on "bad" input than sort in a way that may be
unwanted. Even Ian Kelly gave this as way of coding it.
> At least, not for
> Python 2.x. I'm not sure about Python 3, since it can give an exception
> comparing None to int.
Please not that this post was done in humour (but with truth) to delay
sleep. No offence to Ian or you intended ;).
Happy After-Christmas!
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Custom alphabetical sort Roy Smith <roy@panix.com> - 2012-12-24 11:18 -0500
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 08:40 -0800
Re: Custom alphabetical sort Roy Smith <roy@panix.com> - 2012-12-24 12:40 -0500
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 09:53 -0800
Re: Custom alphabetical sort Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-12-24 18:07 +0000
Re: Custom alphabetical sort Joshua Landau <joshua.landau.ws@gmail.com> - 2012-12-24 18:12 +0000
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 15:19 -0800
Re: Custom alphabetical sort Dave Angel <d@davea.name> - 2012-12-25 01:18 -0500
Re: Custom alphabetical sort Joshua Landau <joshua.landau.ws@gmail.com> - 2012-12-27 01:13 +0000
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 15:19 -0800
Re: Custom alphabetical sort Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-24 22:57 +0000
csiph-web