[Zope-dev] case insensitive sorts

Chris Withers chrisw@nipltd.com
Fri, 05 Jan 2001 12:11:40 +0000


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