On Monday, 24 December 2012 16:32:56 UTC+1, Pander Musubi wrote:
> Hi all,
>
> I would like to sort according to this order:
>
> (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5&
On Monday, December 24, 2012 7:12:43 PM UTC+1, Joshua Landau wrote:
> On 24 December 2012 16:18, Roy Smith wrote:
>
>
>
>
> In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>,
>
> Pander Musubi wrote:
>
>
>
> > Hi all,
>
>
>
>
> > > I'm assuming that doesn't correspond to some standard locale's collating
>
> > > order, so we really do need to roll our own encoding (and that you have
>
> > > a good reason for wanting to do this).
>
> >
>
> > It is for creating a Dutch dictionary.
>
>
>
> Wait a minute.
a pair of dicts. One maps from the code point to a
>
> collating sequence number (i.e. ordinals), the other maps back.
>
> Something like (for python 2.7):
>
>
>
> alphabet = (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5',
>
> '6', '7', '8', '9', 'a', 'A', '?', '?', '?', '?',
>
> [...]
>
> 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z')
>
>
>
> map1 = {c: n for n, c in enumerate(alphabet)}
>
> map2 = {n: c for n, c in enumerate(alphabet)}
OK, similar to Thomas' proposal.
> Next, I would write some functions which encode your strings as lists of
>
> ordinals (and back again)
>
>
>
> def encode(s):
>
>"encode('foo') ==> [34, 19, 19]" # made-up ordinals
>
>return [map1[c] for c in s]
>
>
>
> def decode(l):
>
>"decode([34, 19, 19]) ==> 'foo'"
>
> return ''.join(map2[i] for i in l)
>
>
>
> Use these to convert your strings to lists of ints which will sort as
>
> per your specified collating order, and then back again:
>
>
>
> encoded_strings = [encode(s) for s in original_list]
>
> encoded_strings.sort()
>
> sorted_strings = [decode(l) for l in encoded_strings]
>
>
>
> That's just a rough sketch, and completely untested, but it should get
>
> you headed in the right direction. Or at least one plausible direction.
>
> Old-time perl hackers will recognize this as the Schwartzian Transform.
I will test it and let you know. :) Pander
--
http://mail.python.org/mailman/listinfo/python-list
On Monday, December 24, 2012 5:11:03 PM UTC+1, Thomas Bach wrote:
> On Mon, Dec 24, 2012 at 07:32:56AM -0800, Pander Musubi wrote:
>
> > I would like to sort according to this order:
>
> >
>
> > (' ', '.', '\'', '-',
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')
How can I do this? The default sorted() does not give the desired result.
Thanks,
Pander
--
http://mail.python.org/mailman/listinfo/python-list
On Friday, December 14, 2012 5:22:31 PM UTC+1, Pander Musubi wrote:
> On Friday, December 14, 2012 2:07:51 PM UTC+1, Pander Musubi wrote:
>
> > On Friday, December 14, 2012 1:06:23 AM UTC+1, Steven D'Aprano wrote:
>
> >
>
> > > On Thu, 13 Dec 20
On Friday, December 14, 2012 2:07:51 PM UTC+1, Pander Musubi wrote:
> On Friday, December 14, 2012 1:06:23 AM UTC+1, Steven D'Aprano wrote:
>
> > On Thu, 13 Dec 2012 07:30:57 -0800, Pander Musubi wrote:
>
> >
>
> >
>
> >
>
> > >
On Friday, December 14, 2012 1:06:23 AM UTC+1, Steven D'Aprano wrote:
> On Thu, 13 Dec 2012 07:30:57 -0800, Pander Musubi wrote:
>
>
>
> > I was expecting PyPI. Here is the code, please advise on where to submit
>
> > it:
>
> > http://pastebin.com/
On Thursday, December 13, 2012 2:22:57 PM UTC+1, Bruno Dupuis wrote:
> On Thu, Dec 13, 2012 at 01:51:00AM -0800, Pander Musubi wrote:
>
> > Hi all,
>
> >
>
> > I have created some handy code to encode and decode Unicode General
> > Categories. To which Pyt
Hi all,
I have created some handy code to encode and decode Unicode General Categories.
To which Python Package should I contribute this?
Regards,
Pander
--
http://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo