Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'anyway.': 0.04; 'url:github': 0.09; 'cc:addr:python-list': 0.10; 'naive': 0.16; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:@ 10': 0.27; 'subject:list': 0.28; "skip:' 10": 0.30; 'subject:last': 0.30; 'received:209.85.160.46': 0.32; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'subject:" ': 0.36; "didn't": 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'sure': 0.38; 'header:Received:5': 0.40; '100%': 0.76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=UnLDMCCdy15JOtZOOUBEPBZ35ez6Adf68ccKxNeMBoA=; b=lu1kma5Llx12pDIZp4LJgZtXdTfUc3F2BObjZC15PEnL8l7zABuUaaodNVyGHfwJOu Zre7nX3s58ktRqdbElSexHoI5mo2K0LMzfOHG/PGujkxQIh8O7lBmpi7w59t1p55nNJF mfkvcmf48tRTP6LMWSDoBcdNAIEd6RNhkqGrBbrAgcdV7VcnmgcqUQtjhPm0wCpsteMu nP7P/IiiC2WOATGN64yBH3U2Ik4tW9xx/Nx1iXR4JZP/p0vJr9wOGLdNJ8kLyyhSGwxN V+CT+hiNpr0Bq3LRMKQ013YZlYcyWBj0P+Hwn4cpm7U0+Vkhvs24z4ax8Q7l1yDhaqhD Xnig== Date: Fri, 28 Sep 2012 17:32:17 -0700 From: Demian Brecht User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: dave Subject: Re: creating an artificial "last element" in sort list References: <7cd170ac-bb14-4baa-93ea-530c569d3985@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Python 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348878745 news.xs4all.nl 6895 [2001:888:2000:d::a6]:56361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30440 Apparently gmail hates me and my last response didn't get through: a = ['awefawef', 'awefawfsf', 'awefsdf', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz'] f = filter(lambda s: s == a[-1], a) l = sorted(lst[:-len(f)]) + f Now, not 100% sure about efficiency over large sizes of a, but that's a naive stab at it anyway. -- Demian Brecht @demianbrecht http://demianbrecht.github.com