Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35659
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Custom alphabetical sort |
| Date | 2012-12-27 17:17 -0500 |
| References | <40d108ec-b019-4829-a969-c8ef513866f1@googlegroups.com> <8fc90ea6-4787-4f98-b4b8-c3ae5418d5f0@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1374.1356646698.29569.python-list@python.org> (permalink) |
On 12/27/2012 1:17 PM, wxjmfauth@gmail.com wrote:
> Le lundi 24 décembre 2012 16:32:56 UTC+1, Pander Musubi a écrit :
>> I would like to sort according to this order:
>> (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', 'c', 'C', 'ç', 'Ç', 'd', 'D', 'e', 'E', 'ë', 'Ë', 'é', 'É', 'ê', 'Ê', 'è', 'È', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'ï', 'Ï', 'í', 'Í', 'î', 'Î', 'ì', 'Ì', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'ñ', 'N', 'Ñ', 'o', 'O', 'ö', 'Ö', 'ó', 'Ó', 'ô', 'Ô', 'ò', 'Ò', 'ø', 'Ø', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'ü', 'Ü', 'ú', 'Ú', 'û', 'Û', 'ù', 'Ù', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z')
> One way is to create a list of 2-lists / 2-tuples, like
>
> [(modified_word_1, word_1), (modified_word_2, word_2), ...]
>
> and to use the native sorting wich will use the first element
> modified_word_2 as primary key.
>
> The task lies in the creation of the primary keys.
>
> I did it once for French (seriously) and for German (less
> seriously) scripts. (Only as an exercise for fun).
> >>> rob = ['noduleux', 'noël', 'noèse', 'noétique',
> ... 'nœud', 'noir', 'noirâtre']
> >>> z = list(rob)
> >>> random.shuffle(z)
> >>> z
> ['noirâtre', 'noèse', 'noir', 'noël', 'nœud', 'noétique',
> 'noduleux']
> >>> zo = libfrancais.sortfr(z)
> >>> zo
> ['noduleux', 'noël', 'noèse', 'noétique', 'nœud', 'noir',
> 'noirâtre']
> >>> zo == rob
> True
> PS Py 3.3 warranty: ~30% slower than Py 3.2
Do you have any actual timing data to back up that claim?
If so, please give specifics, including build, os, system, timing code,
and result.
--
Terry Jan Reedy
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