[Zope-dev] case insensitive sorts

Bjorn Pettersen pbjorn at uswest.net
Wed Jan 3 13:20:37 EST 2001


Is this what you want:

>>> ' '.join( [ word.capitalize() for word in 'betty ford'.split() ])
'Betty Ford'

or did you want:

>>> lst = ['Wilbur', 'Carl', 'betty', 'Alan']
>>> lst.sort(lambda x,y: cmp(x.upper(), y.upper()))
>>> lst
['Alan', 'betty', 'Carl', 'Wilbur']

-- bjorn

Chris Withers wrote:

> 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




More information about the Python-list mailing list