Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35472
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'def': 0.10; 'dec': 0.15; "skip:' 30": 0.15; '24,': 0.16; 'character:': 0.16; 'instead:': 0.16; 'string': 0.17; 'wrote:': 0.17; '>>>': 0.18; 'email addr:gmail.com>': 0.20; '>>>': 0.22; '>': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'words': 0.29; 'skip:& 10': 0.29; 'probably': 0.29; 'error': 0.30; "skip:' 20": 0.32; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'characters': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'more': 0.63; '8bit%:50': 0.65; 'clearer': 0.84; 'to:name:python': 0.84 |
| 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=bzW2MH3ZXtvr9wySVNDQY1os3opvtuNaRoMLZbC632Q=; b=TQgkydP0Qo57LBD+qG4b+MdgW6u3mYDDwC0rfWgT24mmje/BjNBDqGeWjsSHzYALcT oS4wtEDVyez38BOxF43qFUeg7l355TQvc41QMRVlFcia8g2bTKUosmqCyq+odNrbsxZj UfSGpCkax86yY8A7YCLjv5k8fThBoIc60Q1htrJE99DQC84yItXPOTWIyaToyjxyz8Tn Xf/0kQqWUeJ+DP8LJ/bEZ2sQTtiRyR0yN1c8ViIiYmhG2ij26kP0E/vich92DamU/eGN AwDiY9hfEdj9Uh7slthU3i0JuV3JYCwYOgn9BfDAMxaGJfF0OANzzlrHFf7/muPQ49GE qrsA== |
| MIME-Version | 1.0 |
| In-Reply-To | <0181c694-7605-4857-8469-baf214c85820@googlegroups.com> |
| References | <40d108ec-b019-4829-a969-c8ef513866f1@googlegroups.com> <mailman.1257.1356365475.29569.python-list@python.org> <0181c694-7605-4857-8469-baf214c85820@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 24 Dec 2012 10:29:29 -0700 |
| Subject | Re: Custom alphabetical sort |
| To | Python <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=047d7b33d650ef45cb04d19c8b70 |
| 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.1260.1356370208.29569.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1356370208 news.xs4all.nl 6905 [2001:888:2000:d::a6]:37221 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:35472 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Dec 24, 2012 9:37 AM, "Pander Musubi" <pander.musubi@gmail.com> wrote:
> > >>> ''.join(sorted(random.sample(cs, 20), key=d.get))
> >
> > '5aAàÀåBCçËÉíÎLÖøquùx'
>
> This doesn't work for words with more than one character:
Try this instead:
def collate(x):
return list(map(d.get, x))
sorted(data, key=collate)
I would also probably change "d.get" to "d.__getitem__" for a clearer error
message in the case the string contains characters that it doesn't know how
to sort.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 07:32 -0800
Re: Custom alphabetical sort Thomas Bach <thbach@students.uni-mainz.de> - 2012-12-24 17:11 +0100
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 08:34 -0800
Re: Custom alphabetical sort Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-24 10:29 -0700
Re: Custom alphabetical sort Pander Musubi <pander.musubi@gmail.com> - 2012-12-24 08:34 -0800
Re: Custom alphabetical sort wxjmfauth@gmail.com - 2012-12-27 10:17 -0800
Re: Custom alphabetical sort Terry Reedy <tjreedy@udel.edu> - 2012-12-27 17:17 -0500
Re: Custom alphabetical sort Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-27 16:17 -0700
Re: Custom alphabetical sort wxjmfauth@gmail.com - 2012-12-28 02:27 -0800
csiph-web