Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'list?': 0.07; 'string': 0.09; 'arguments': 0.09; 'file)': 0.09; 'python': 0.11; 'sorting': 0.16; 'subject:Case': 0.16; 'subject:insensitive': 0.16; 'unicode?': 0.16; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'unicode': 0.24; 'ones.': 0.31; 'ordinary': 0.31; 'file': 0.32; 'text': 0.33; 'subject: (': 0.35; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'method': 0.36; 'so,': 0.37; 'others.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'john': 0.61 X-Originating-IP: [82.17.196.67] X-Spam: 0 X-Authority: v=2.1 cv=dY0O3Bne c=1 sm=1 tr=0 a=PBogQOoCmbW3e6QIHwVAZw==:117 a=PBogQOoCmbW3e6QIHwVAZw==:17 a=2fDfVs0_6TAA:10 a=IkcTkHD0fZMA:10 a=NLZqzBF-AAAA:8 a=-Bq9tubEPRaTXilnoYUA:9 a=QEXdDO2ut3YA:10 a=F-_vu_hY_r0A:10 a=1qSfhOjUMAIA:10 a=JNozzAaekeMA:10 Date: Fri, 23 Jan 2015 17:00:03 +0000 From: John Sampson User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Case-insensitive sorting of strings (Python newbie) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422032384 news.xs4all.nl 2839 [2001:888:2000:d::a6]:45782 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:84354 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