[Zope-dev] case insensitive sorts

Shane Hathaway shane@digicool.com
Thu, 07 Dec 2000 10:54:06 -0500


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