[Zope-dev] case insensitive sorts

Toby Dickenson tdickenson@geminidataloggers.com
Thu, 07 Dec 2000 11:11:51 +0000


On Wed, 06 Dec 2000 18:00:31 +0000, Chris Withers <chrisw@nipltd.com>
wrote:

>(reasons of course would be helpful, particularly if you want it to stay
>like it is ;-)

I noticed the smiley, so Im not sure how serious the suggestion is.

Ill bite anyway:


1. Python doesnt distinguish between 8-bit-strings and byte arrays.
(for example, ZODB uses 8-byte-long 'strings' as oids). Do you want a
casewise sort for byte arrays too?


2. 'sort' uses 'cmp'; so effectively you are asking for string's cmp
to be case insensitve. Can you demonstrate a case-sensitive collation
function that is as simple as your case-insensitive one:
>def _default_sort(x,y):
>    return cmp(string.lower(x),string.lower(y))


3. ZCatalog stores objects in a pre-sorted order. Changing the sort
order of any object (not just strings) would break *all* existing
ZCatalog instances that store mixed case strings. (and other
applications too - the python language reference documents that this
assmption is safe at least until python3k)




Toby Dickenson
tdickenson@geminidataloggers.com