Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84354

Case-insensitive sorting of strings (Python newbie)

Return-Path <jrs.idx@ntlworld.com>
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 <jrs.idx@ntlworld.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18040.1422032384.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Case-insensitive sorting of strings (Python newbie) John Sampson <jrs.idx@ntlworld.com> - 2015-01-23 17:00 +0000
  Re: Case-insensitive sorting of strings (Python newbie) Michael Ströder <michael@stroeder.com> - 2015-01-23 18:10 +0100
  Re: Case-insensitive sorting of strings (Python newbie) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 04:56 +1100

csiph-web