Status of the #6904 ticket (case insensitive sort in dictsort)

50 views
Skip to first unread message

Douglas Soares de Andrade

unread,
Oct 15, 2009, 7:44:33 AM10/15/09
to Django developers
Hi all,

What is the status of the following ticket ?

http://code.djangoproject.com/ticket/6904

I just had this issue in Django 1.1 and i totally agree with mathwizard
said.

Thanks a lot

Waylan Limberg

unread,
Oct 15, 2009, 11:37:19 AM10/15/09
to django-d...@googlegroups.com
On Thu, Oct 15, 2009 at 7:44 AM, Douglas Soares de Andrade
<dsan...@gmail.com> wrote:
>
> Hi all,
>
> What is the status of the following ticket ?
>
> http://code.djangoproject.com/ticket/6904
>

Well, the "Triage Stage" is currently set at "Design decision needed"
which means that it's waiting for a core dev to review the ticket and
either accept or reject it.

> I just had this issue in Django 1.1 and i totally agree with mathwizard
> said.

I don't - and I just posted a comment to the ticket explaining why. If
you (or anyone) wants case-insensitive sorting, just create your own
custom filter that does just that. You could even copy the built-in
filter to your own project/app and use it with a one or two line
change.

--
----
\X/ /-\ `/ |_ /-\ |\|
Waylan Limberg

Michael P. Jung

unread,
Oct 16, 2009, 10:01:21 AM10/16/09
to django-d...@googlegroups.com
The collation for other languages than English is not that simple.

e.g. the German Umlaut "ä" is often seen equivalent to "ae" when
ordering lists. Thus a list like [u'baf', u'bäx', u'baz'] would be
sorted [u'bäx', u'baf', u'baz']. There are even some collations that
just treat 'ä' as an 'a' and some that order 'a' < 'ä'.

In short: The ordering should depend on the locale being used and not on
some .lower() magic.


Ordering strings depending on the language, hat's what locale.strcoll is
good for:

http://code.activestate.com/recipes/442492/

And don't just use locale.strxfrm as suggested in the user comments
because it is buggy in python 2.5 and doesn't work with unicode strings:

http://bugs.python.org/issue2481


Maybe django should provide a <insert-good-name-here> function inside
the django.utils module and provide sorting based on the current locale
and/or language of the current request. I guess it's an often made
mistake to just rely on the string ordering while in reality wanting
ordering based on the locale.


--mp

Douglas Soares de Andrade

unread,
Oct 16, 2009, 7:13:09 AM10/16/09
to django-d...@googlegroups.com
Michael P. Jung escreveu:

Great post Michael, i did a python module to do that, and i called the
function isorted (but its principle can be used in a django filter too).

Here is the code:

http://pastebin.com/f1ecba5c7

Please, if you have any comments on how to improve it, or if i have to
do something to add it to django (im a newbie in django core
development) just say it and im sure to do my best.

Also sent this to Marinho to see if we could put in django-plus.

Thanks a lot and i really hope that we can find a way to improve this in
django.

Reply all
Reply to author
Forward
0 new messages