What is the best way to sort a list of words with the case insensitive?
Since Python 2.4 (I guess it's 2.4), sort has the option key:
>>> import string >>> l = ["a","B","c","D"] >>> l.sort(key=string.lower) >>> l ['a', 'B', 'c', 'D']
Here's a way for < 2.4:
>>> l.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
Mawe, I put your suggestions into program and they work well!
Thank you much.
Just started with Python so i am using 2.4