[Zope-dev] case insensitive sorts

Rik Hoekstra rik.hoekstra@inghist.nl
Wed, 6 Dec 2000 22:35:27 +0100


> Andy McKay wrote:
>
> > Minor nit and patch: I've found that really for me what users want to
see is
> > a case insensitive sort of objects, not the current python case
sensitive
> > sort. So that the order of objects from dtml-in and tree is a, A, b, B
as
> > apposed to A, B, a, b.
> >
> > Anyway Ive patched dtml-in and dtml-tree to do this sort on a
ignore_case
> > tag. Is this useful to anyone else? And Ive thought of patching my Zope
so
> > this is the default behaviour.... what does anyone else think. The next
> > thing to patch is ZCatalog...
>
>
> The way I approached this was to have a ZPatterns attribute provider, or
> a method, that provides a modified version of the value I want to sort on.
>
> For example, I have a load of documents and folders with titles like
>
>   Big Folder
>
>   brown document
>
>   "Berries for Cooking" list
>
> I wanted to present these sorted by non-case-sensitive first letter or
> number. So, I made a method "title_for_sorting" that stripped off any
> punctuation at the start, and returned the first 20 characters in all
> lower case.  In this case, as it was a ZPatterns application, the method
> was presented as an attribute of the object using some skin-script. I
> used this attribute as a field-index in my SiteIndex ZCatalog.
>
> The reason I mention this is that sometimes case-insensitivity is not
> enough for sensible sorting. In this case, I had to strip out
> punctuation too.

Hm, reading this... just a loose comment.
In light of the awkward search interface of ZCatalogs, would it be a good
idea to make a search interface for ZCatalog ZPatterns based? This would add
the possibility to make it configurable wrt case sensitivity, and to do nice
things with ANDing and ORing different kinds of indexes.
The only thing I can't judge whether it would be possible to make this
generic enough.

for-what-it's-worth

Rik