Case-insensitive sorting of strings (Python newbie)

John Sampson jrs.idx at ntlworld.com
Fri Jan 23 12:00:03 EST 2015


I notice that the string method 'lower' seems to convert some strings 
(input from a text file) to Unicode but not others.
This messes up sorting if it is used on arguments of 'sorted' since 
Unicode strings come before ordinary ones.

Is there a better way of case-insensitive sorting of strings in a list? 
Is it necessary to convert strings read from a plaintext file
to Unicode? If so, how? This is Python 2.7.8.

Regards

John Sampson



More information about the Python-list mailing list