2
Contributors
2
Replies
5
Views
11 Years
Discussion Span
Last Post by bumsfeld
0

Hi!

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

Regards, mawe

0

Mawe, I put your suggestions into program and they work well!

Thank you much.

Just started with Python so i am using 2.4

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.