[Zope-dev] case insensitive sorts

2000-12-06 Thread Andy McKay

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...


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-06 Thread Chris Withers

Andy McKay wrote:
> 
> Anyway Ive patched dtml-in and dtml-tree to do this sort on a ignore_case
> tag. Is this useful to anyone else?

yes! :-)

> 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...

To be honest, why not just mail Guido (not literally! ;-) and suggest a
change to python. IMNSHO, the default sort isn't as useful as it could
be because of this and should be made to behave as you describe rather
than like it is now. Pretty much every sort I do of strings in a python
project uses the sort method below insetad of the default. This is a
pain.

def _default_sort(x,y):
return cmp(string.lower(x),string.lower(y))

Who thinks the default python sort should stay like it is? Who thinks it
should change? 
(reasons of course would be helpful, particularly if you want it to stay
like it is ;-)

cheers,

Chris

PS: With this being a general python issue, IMO, I've cc'ed to the
python list, hope I'm not out of order...

PPS: Is there such a thing as [EMAIL PROTECTED], if you see what I
mean?

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-06 Thread Steve Alexander

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.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-06 Thread Andy McKay

Oh yeah for the ZCatalog I have two indexes one upper case and one lower
case for some of my classes. No problemo. My area to attack though is the
standard views such as the management interface...

How's life in Lancaster? Went to school there and grew up in Garstang

--
  Andy McKay, Developer.
  ActiveState.

- Original Message -
From: "Steve Alexander" <[EMAIL PROTECTED]>
To: "Andy McKay" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, December 06, 2000 11:03 AM
Subject: Re: [Zope-dev] case insensitive sorts


> 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.
>
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
> http://www.cat-box.net
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-06 Thread Dieter Maurer

Andy McKay writes:
 >  what does anyone else think

I would not like it.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-06 Thread Rik Hoekstra



> 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


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Chris Withers

Dieter Maurer wrote:
> 
> Andy McKay writes:
>  >  what does anyone else think
> 
> I would not like it.

Why not? ;-)

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Toby Dickenson

On Wed, 06 Dec 2000 18:00:31 +, Chris Withers <[EMAIL PROTECTED]>
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
[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Shane Hathaway

Chris Withers wrote:
> Who thinks the default python sort should stay like it is? Who thinks it
> should change?
> (reasons of course would be helpful, particularly if you want it to stay
> like it is ;-)

Python's sort() lets you sort based on not only strings but also tuples,
lists, and numbers, which is a very useful feature.  Thus sort() is
intended to be a highly generalized method.  It is useful but not ideal
for sorting text strings.  What you *really* want is a second method,
perhaps in a new module (called "textops" or something similar) that
would also include multilingual text splitters and other utilities for
working with human-readable text.

BTW have you ever tried this?

  data = [[], (), 0, '', {}]
  data.sort()
  print data

The one thing I wonder is whether the sort order is consistent between
different versions of Python.  I get:

  [0, {}, [], '', ()]

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Toby Dickenson

On Thu, 07 Dec 2000 10:54:06 -0500, Shane Hathaway
<[EMAIL PROTECTED]> wrote:

>The one thing I wonder is whether the sort order is consistent between
>different versions of Python.

I actually have a Collector bug report on exactly this question.
http://classic.zope.org:8080/Collector/1219/view

(Status: pending. and has been for 8 months :-(

In reality, I think it is only a theoretical problem. The current
implementation takes much more care than it is required to by the
language reference. Indeed, extra effort was taken in Python 2.0's
implementation of Unicode.


Toby Dickenson
[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Dieter Maurer

Chris Withers writes:
 > Dieter Maurer wrote:
 > > Andy McKay writes:
 > >  >  what does anyone else think
 > > 
 > > I would not like it.
 > 
 > Why not? ;-)
I would not like to see this sort order in the management
screens, because I use capitalization to ensure that
essential objects are at the top of the object list.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Andy McKay

But thats a result of the sorting...

anyway I have in and tree patched, I'll post them tonight when I get home
and let people do what they want.

--
  Andy McKay, Developer.
  ActiveState.

- Original Message -
From: "Dieter Maurer" <[EMAIL PROTECTED]>
To: "Chris Withers" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, December 07, 2000 12:00 PM
Subject: Re: [Zope-dev] case insensitive sorts


> Chris Withers writes:
>  > Dieter Maurer wrote:
>  > > Andy McKay writes:
>  > >  >  what does anyone else think
>  > >
>  > > I would not like it.
>  >
>  > Why not? ;-)
> I would not like to see this sort order in the management
> screens, because I use capitalization to ensure that
> essential objects are at the top of the object list.
>
>
> Dieter
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-07 Thread Andy McKay

 > 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)

Looking at this and other reasons I won't try to hack ZCatalog. I'll stick
to making lower case string indexes Seems the safest all around.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2000-12-08 Thread Steve Alexander

Shane Hathaway wrote:

>
> BTW have you ever tried this?
> 
>   data = [[], (), 0, '', {}]
>   data.sort()
>   print data
> 
> The one thing I wonder is whether the sort order is consistent between
> different versions of Python.  I get:
> 
>   [0, {}, [], '', ()]

This is consistent across Python versions. The sequence types are in 
alphabetical order:

   Dictionary, List, String, Tuple

This is documented somewhere.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Chris Withers

Shane Hathaway wrote:
> 
> Python's sort() lets you sort based on not only strings but also tuples,
> lists, and numbers, which is a very useful feature.  Thus sort() is
> intended to be a highly generalized method.  It is useful but not ideal
> for sorting text strings.  What you *really* want is a second method,
> perhaps in a new module (called "textops" or something similar) that
> would also include multilingual text splitters and other utilities for
> working with human-readable text.

I agree that's a good idea, but all I'm talking about is the simple case
of sorting strings, in which python's current implementation isn't very
helpful and I don't see any situation where sorting:

Andrew
David
Wayne
bart
sophie

is better than sorting:

Andrew
bart
David
sophie
Wayne

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Chris Withers

Dieter Maurer wrote:
> 
> Chris Withers writes:
>  > Dieter Maurer wrote:
>  > > Andy McKay writes:
>  > >  >  what does anyone else think
>  > >
>  > > I would not like it.
>  >
>  > Why not? ;-)
> I would not like to see this sort order in the management
> screens, because I use capitalization to ensure that
> essential objects are at the top of the object list.

Hmmm... that's like saying you'd rather not have a memory leak fixed
because it gives you an excuse to buy more RAM ;-)

*grinz*

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Chris Withers

Toby Dickenson 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.

It was serious, the smiley was 'cos I couldn't understand why anyone
would want it to stay like it is :-)

> 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?

I don't know. Show me why this is bad :-)

> 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))

I see your point. I guess cmp is implemented in C?
How about a third optional argument?

def _case_sensitive_sort(x,y):
return cmp(x,y,string.CASE_SENSITIVE)

def _default_sort(x,y):
return cmp(x,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)

Sorry, don't qutie follow this... explanation for a simpleton? ;-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] case insensitive sorts

2001-01-03 Thread Andy Dawkins

> Dieter Maurer wrote:
> >
> > Chris Withers writes:
> >  > Dieter Maurer wrote:
> >  > > Andy McKay writes:
> >  > >  >  what does anyone else think
> >  > >
> >  > > I would not like it.
> >  >
> >  > Why not? ;-)
> > I would not like to see this sort order in the management
> > screens, because I use capitalization to ensure that
> > essential objects are at the top of the object list.
>
> Hmmm... that's like saying you'd rather not have a memory leak fixed
> because it gives you an excuse to buy more RAM ;-)
>
> *grinz*
>
> Chris
>

I would have said its like saying your not going to fix the hole in your
water pipe because you use it to fill up your kettle without getting out of
bed, and if you fixed it then you would have to walk to the sink.

:-)

Needless to say I agree with Chris.

-Andy


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Phil Harris

See below (nothing earth shattering tho) ;)

- Original Message -
From: "Chris Withers" <[EMAIL PROTECTED]>
To: "Shane Hathaway" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 03, 2001 10:58 AM
Subject: Re: [Zope-dev] case insensitive sorts


> Shane Hathaway wrote:
> >
> > Python's sort() lets you sort based on not only strings but also tuples,
> > lists, and numbers, which is a very useful feature.  Thus sort() is
> > intended to be a highly generalized method.  It is useful but not ideal
> > for sorting text strings.  What you *really* want is a second method,
> > perhaps in a new module (called "textops" or something similar) that
> > would also include multilingual text splitters and other utilities for
> > working with human-readable text.
>
> I agree that's a good idea, but all I'm talking about is the simple case
> of sorting strings, in which python's current implementation isn't very
> helpful and I don't see any situation where sorting:
>
> Andrew
> David
> Wayne
> bart
> sophie
>
> is better than sorting:
>
> Andrew
> bart
> David
> sophie
> Wayne

That's only because you use NT (ach spit). ;)

>
> cheers,
>
> Chris
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] case insensitive sorts

2001-01-03 Thread Andy Dawkins

> > Andrew
> > David
> > Wayne
> > bart
> > sophie
> >
> > is better than sorting:
> >
> > Andrew
> > bart
> > David
> > sophie
> > Wayne
> 
> That's only because you use NT (ach spit). ;)
> 

Thats not actually true.

It is how python behaves on WinNt, Win9X, Linux, etc
(I have tested this)

-Andy

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Casey Duncan

Andy Dawkins wrote:
> 
> > Dieter Maurer wrote:
> > >
> > > Chris Withers writes:
> > >  > Dieter Maurer wrote:
> > >  > > Andy McKay writes:
> > >  > >  >  what does anyone else think
> > >  > >
> > >  > > I would not like it.
> > >  >
> > >  > Why not? ;-)
> > > I would not like to see this sort order in the management
> > > screens, because I use capitalization to ensure that
> > > essential objects are at the top of the object list.
> >
> > Hmmm... that's like saying you'd rather not have a memory leak fixed
> > because it gives you an excuse to buy more RAM ;-)
[snip]
> 
> I would have said its like saying your not going to fix the hole in your
> water pipe because you use it to fill up your kettle without getting out of
> bed, and if you fixed it then you would have to walk to the sink.
[snip]

I have to agree with Dieter here that a useful side affect is lost if
the sort was case insensitive. I myself found it a bit strange at first,
but now I am using different naming rules for different objects so they
mingle together. (i.e. Interface level objects get caps, logic level
objects don't).

Your analogies imply that this behavior is a bug or an unintended flaw
in the design. I would argue that it is intentional. Unix file systems
work the same way. Try doing an "ls" with mixed case files and you'll
see what I mean.

Anyhow if this goes away, I think the management interface would need to
have ability to sort by something other than id to compensate. To a
certain degree a sort by meta type would be similar for me, but
certainly less flexible, and wouldn't help compensate for the scaling
problems of the ZMI.

It just goes to show how even obscure and subtle features like this can
be important (to some at least). At least now you have the flexibility
to not use this "feature" by using the same naming conventions for
everything.
-- 
| Casey Duncan
| Kaivo, Inc.
| [EMAIL PROTECTED]
`-->

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] case insensitive sorts

2001-01-03 Thread Andy Dawkins

> Your analogies imply that this behavior is a bug or an unintended flaw
> in the design. I would argue that it is intentional. Unix file systems
> work the same way. Try doing an "ls" with mixed case files and you'll
> see what I mean.
> 

It isn't a flaw.  It seems as though it was overlooked.

The sort on text works by sorting the data by its ascii value.
Capital letters have a lower ascii value than lower case letters.
i.e.
A-Z = 65 - 90
a-z = 97 - 122


The arguement is that the sort should probably go
AaBbCcDdEeFf.etc

-Andy



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Casey Duncan

Andy Dawkins wrote:
> 
> > Your analogies imply that this behavior is a bug or an unintended flaw
> > in the design. I would argue that it is intentional. Unix file systems
> > work the same way. Try doing an "ls" with mixed case files and you'll
> > see what I mean.
> >
> 
> It isn't a flaw.  It seems as though it was overlooked.
> 
> The sort on text works by sorting the data by its ascii value.
> Capital letters have a lower ascii value than lower case letters.
> i.e.
> A-Z = 65 - 90
> a-z = 97 - 122
> 
> The arguement is that the sort should probably go
> AaBbCcDdEeFf.etc
> 
> -Andy
> 
My point is that the sorting is intentionally Unix-like and case
sensitive on purpose. Not due to laziness. But, perhaps the reason Unix
is like that to begin with is due to laziness anyhow 8^). We'll never
know for sure.

-- 
| Casey Duncan
| Kaivo, Inc.
| [EMAIL PROTECTED]
`-->

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Andy McKay

My main point is that the user who visits my site does not care about
python, Unix, NT or any wierd metaphors about kettles.

They want information fast and most users expect case insensitive sorts. Its
simpler and easy. I think having the ignore_case option for a -tree and -in
helps Zope by increasing the ease of development and friendliness to the
user.

--
  Andy McKay, Developer.
  ActiveState.


- Original Message -
From: "Casey Duncan" <[EMAIL PROTECTED]>
To: "Andy Dawkins" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, January 03, 2001 8:17 AM
Subject: Re: [Zope-dev] case insensitive sorts


> Andy Dawkins wrote:
> >
> > > Your analogies imply that this behavior is a bug or an unintended flaw
> > > in the design. I would argue that it is intentional. Unix file systems
> > > work the same way. Try doing an "ls" with mixed case files and you'll
> > > see what I mean.
> > >
> >
> > It isn't a flaw.  It seems as though it was overlooked.
> >
> > The sort on text works by sorting the data by its ascii value.
> > Capital letters have a lower ascii value than lower case letters.
> > i.e.
> > A-Z = 65 - 90
> > a-z = 97 - 122
> >
> > The arguement is that the sort should probably go
> > AaBbCcDdEeFf.etc
> >
> > -Andy
> >
> My point is that the sorting is intentionally Unix-like and case
> sensitive on purpose. Not due to laziness. But, perhaps the reason Unix
> is like that to begin with is due to laziness anyhow 8^). We'll never
> know for sure.
>
> --
> | Casey Duncan
> | Kaivo, Inc.
> | [EMAIL PROTECTED]
> `-->
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Chris Withers

Andy McKay wrote:
> 
> They want information fast and most users expect case insensitive sorts. Its
> simpler and easy. I think having the ignore_case option for a -tree and -in
> helps Zope by increasing the ease of development and friendliness to the
> user.

And my point was that this is so universally true that the _pthyon_ sort
function (which is at fault here) should be fixed :-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Andy McKay

Hmm im actually not so sure on that. Currently you can do a sort either way,
if you fix it so its only case sensitive we'll end up like Visual Basic :)
Fixing python is a question for the python list and I'd be scared to ask it
there...

--
  Andy McKay, Developer.
  ActiveState.


- Original Message -
From: "Chris Withers" <[EMAIL PROTECTED]>
To: "Andy McKay" <[EMAIL PROTECTED]>
Cc: "Casey Duncan" <[EMAIL PROTECTED]>; "Andy Dawkins" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, January 03, 2001 8:46 AM
Subject: Re: [Zope-dev] case insensitive sorts


> Andy McKay wrote:
> >
> > They want information fast and most users expect case insensitive sorts.
Its
> > simpler and easy. I think having the ignore_case option for a -tree
and -in
> > helps Zope by increasing the ease of development and friendliness to the
> > user.
>
> And my point was that this is so universally true that the _pthyon_ sort
> function (which is at fault here) should be fixed :-)
>
> cheers,
>
> Chris
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Chris Withers

Andy McKay wrote:
> 
> Hmm im actually not so sure on that. Currently you can do a sort either way,
> if you fix it so its only case sensitive we'll end up like Visual Basic :)

Actually, I'd like to see it 'fixed' so it's only case insensitive:

Alan
betty
Carl
Wilbur

> Fixing python is a question for the python list and I'd be scared to ask it
> there...

I'm sure I copied one of these messages to the python list for that very
reason but it didn't get any response. Ah well, I'll copy this one there
as well and see what happens ;-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-03 Thread Dieter Maurer

Chris Withers writes:
 > Andrew
 > bart
 > David
 > sophie
 > Wayne
Why in hell do you switch caseness for similar objects?

If you apply some naming conventions, such as
"objects start with a Capital letter, verb with a lowercase letter",
you may find Python's sorting order usefull.



Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-04 Thread Chris Withers

Dieter Maurer wrote:
> 
> Chris Withers writes:
>  > Andrew
>  > bart
>  > David
>  > sophie
>  > Wayne
> Why in hell do you switch caseness for similar objects?

Who said anything about objects? I was just talking about lists of
strings and in general, people prefer sorting based on the character to
take precedence over sorting based on the case of that character.

Sadly, python's default sort does it the other way round :-(

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-04 Thread Tres Seaver

Chris Withers <[EMAIL PROTECTED]> wrote:
 
> Andy McKay wrote:
> > 
> > They want information fast and most users expect case insensitive sorts. Its
> > simpler and easy. I think having the ignore_case option for a -tree and -in
> > helps Zope by increasing the ease of development and friendliness to the
> > user.
> 
> And my point was that this is so universally true that the _pthyon_ sort
> function (which is at fault here) should be fixed :-)

Python's sort already allows you to pass an alternate comparison
function::

 [/var/home/tres] $ python
 Python 1.5.2 (#1, Feb  1 2000, 16:32:16)  [GCC egcs-2.91.66
19990314/Linux (egcs- on linux-i386
 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 >>> foo = [ 'z', 'y', 'x' ]
 >>> foo.sort()
 >>> foo
 ['x', 'y', 'z']
 >>> foo.sort( lambda x, y: cmp(y,x) )
 >>> foo
 ['z', 'y', 'x']

I believe Andy's patch makes use of this feature.  You are missing
a couple of points if you *require* a case-insensitive sort:

 * collation (which letters belong together) is highly locale
   sensitive (e.g., does a-accent-grave sort with a? etc.)

 * Should strings which differ only in case be equal (*NOT*!)

Tres.
-- 
===
Tres Seaver[EMAIL PROTECTED]
Digital Creations "Zope Dealers"   http://www.zope.org

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] case insensitive sorts

2001-01-04 Thread Andy Dawkins

>
>  * collation (which letters belong together) is highly locale
>sensitive (e.g., does a-accent-grave sort with a? etc.)
>

A Fair point.

The answer is whatever seems _naturally_ correct from a users point of view.
I think the answer is yes.

Elephant
entropy
écrit
élan

i.e. In the order in which they would appear in a dictionary.

>  * Should strings which differ only in case be equal (*NOT*!)
>

'Ant' is not equal to 'ant' but 'Ant'<'ant'<'Ante'<'ante'

i.e.

Ant
ant
Ante
ante

Would be a sensible sort order.

I hope that makes things a bit clearer.

-Andy


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-04 Thread Shane Hathaway

Chris Withers wrote:
> 
> Dieter Maurer wrote:
> >
> > Chris Withers writes:
> >  > Andrew
> >  > bart
> >  > David
> >  > sophie
> >  > Wayne
> > Why in hell do you switch caseness for similar objects?
> 
> Who said anything about objects? I was just talking about lists of
> strings and in general, people prefer sorting based on the character to
> take precedence over sorting based on the case of that character.
> 
> Sadly, python's default sort does it the other way round :-(

This is not wrong.  Again, if the default sort tried to sort
case-insensitively, it would yield incorrect results for existing code
that sorts lists of strings containing data rather than text.  And
again, what you really want is a "textops" module that does something
like this:

def sort_strings(data):
  sortable_data = list(map(lambda s: (lower(s), s), data))
  sortable_data.sort()
  return map(lambda s: s[1], sortable_data)

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-04 Thread Shane Hathaway

Shane Hathaway wrote:
> def sort_strings(data):
>   sortable_data = list(map(lambda s: (lower(s), s), data))
>   sortable_data.sort()
>   return map(lambda s: s[1], sortable_data)

... Or better, you could pass a comparison function to sort() like Tres
suggested.  :-)

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-04 Thread Dieter Maurer

Chris Withers writes:
 > Dieter Maurer wrote:
 > > 
 > > Chris Withers writes:
 > >  > Andrew
 > >  > bart
 > >  > David
 > >  > sophie
 > >  > Wayne
 > > Why in hell do you switch caseness for similar objects?
 > 
 > Who said anything about objects?
Maybe, I should have said subjects.

Your example strings seem to name persons.
It is very strange (and should be punished, as it is by
Python's default sort ;-)) to use caseness inconsistently
for these same type subjects/objects/entities (whatever you like).

I am not against an option to specify what comparison function should
be used for sorting (when I would implement it, I would probably
follow Python's sort interface and provide an optional function
rather than have a collection of attributes specifying
the sort order).

However, I am against a change of the sort order
in the *management interface* (unless I can easily switch back).
The reason: I make sensible use of the ASCII based sort
order and would not like to loose it.



Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] case insensitive sorts

2001-01-05 Thread Chris Withers

Shane Hathaway wrote:
> 
> Shane Hathaway wrote:
> > def sort_strings(data):
> >   sortable_data = list(map(lambda s: (lower(s), s), data))
> >   sortable_data.sort()
> >   return map(lambda s: s[1], sortable_data)
> 
> ... Or better, you could pass a comparison function to sort() like Tres
> suggested.  :-)

This is where this whole thread started ;-)
We end up using a comparision function every time we call sort, which is
messy and results in a lot of duplicated code...

My suggestion was for the default sort function to change so that when
you want the sorting that makes sense to humans, you'd just have to do:

list.sort()

...and when you wanted sort as it is now, then you could something like:

list.sort(lambda x, y: old_cmp(y,x)) 

But this thread has lost noth its ends, so to speak, so I shall duck out
;-)

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )