Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'else:': 0.03; 'elif': 0.05; 'received:192.168.178': 0.07; "'')": 0.09; 'quiet': 0.09; 'subject:characters': 0.09; 'def': 0.12; 'changes': 0.15; '120,': 0.16; 'b):': 0.16; 'goebel': 0.16; 'lot!': 0.16; 'received:192.168.178.20': 0.16; 'say.': 0.16; 'skip:n 70': 0.16; 'uppercase': 0.16; 'do.': 0.18; 'bit': 0.19; 'module': 0.19; 'import': 0.22; 'print': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'skip': 0.24; 'sorry,': 0.24; 'helpful': 0.24; 'looks': 0.24; "i've": 0.25; 'compare': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'skip:- 40': 0.29; 'topic': 0.29; "i'm": 0.30; 'gives': 0.31; 'that.': 0.31; 'helpful.': 0.31; 'url:python': 0.33; 'cases': 0.33; 'but': 0.35; 'there': 0.35; "didn't": 0.36; 'shows': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'similar': 0.36; 'url:org': 0.36; 'example,': 0.37; 'thank': 0.38; 'ends': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'letters': 0.60; 'received:217': 0.63; 'more': 0.64; 'worth': 0.66; 'subjectcharset:utf-8': 0.72; 'limits,': 0.84 Date: Wed, 30 Oct 2013 21:17:04 +0100 From: Ulrich Goebel User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Python Subject: Re: sorting german characters =?UTF-8?B?w6TDtsO8Li4uIHNvbHZlZA==?= References: <52715232.5020108@fam-goebel.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 30 Oct 2013 21:19:29 +0100 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: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383164370 news.xs4all.nl 15917 [2001:888:2000:d::a6]:39309 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58108 Hi, Am 30.10.2013 19:48, schrieb Skip Montanaro: > Perhaps this? http://stackoverflow.com/questions/816285/where-is-pythons-best-ascii-for-this-unicode-database There I found the module unidecode (http://pypi.python.org/pypi/Unidecode), and I found it very helpful. Thanks a lot! So my function normal() now looks like this: from unidecode import unidecode def normal (s): r = s r = r.strip() # take away blanks at the ends r = r.replace(u' ', '') # take away all other blanks r = unidecode(r) # makes the main work # - see the docu of unidecode r = r.upper() # changes all to uppercase letters return r def compare (a, b): aa = normal(a) bb = normal(b) if aa < bb: return -1 elif aa == bb: return 0 else: return 1 For the "normal" cases, that works quiet perfect - as I want it to do. For more (extreme) difficult cases there are even limits, but they are even wide limits, I would say. For example, print normal(u'-£-¥-Ć-û-á-€-Đ-ø-ț-ff-ỗ-Ể-ễ-ḯ-ę-ä-ö-ü-ß-') gives -PS-Y=-C-U-A-EU-D-O-T-FF-O-E-E-I-E-A-O-U-SS- That shows a bit of what unidecode does - and what it doesn't. > There is also a rather long-ish recent topic on a similar topic that > might be worth scanning as well. Sorry, I didn't find that. > I've no direct/recent experience with this topic. I'm just an > interested bystander. But even a helpful bystander. Thank You! Ulrich -- Ulrich Goebel Paracelsusstr. 120, 53177 Bonn