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


Groups > comp.lang.python > #30438

Re: creating an artificial "last element" in sort list

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dihedral88888@googlemail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; "'a'": 0.07; 'friday,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; 'anyway': 0.11; 'suggest': 0.11; "'b'": 0.16; "'b',": 0.16; "['a',": 0.16; 'ascending': 0.16; 'preprocess': 0.16; 'wrote:': 0.17; 'appears': 0.18; 'code.': 0.20; 'sort': 0.21; 'not,': 0.21; 'cc:2**0': 0.23; 'elements': 0.23; 'references': 0.23; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'subject:list': 0.28; 'run': 0.28; 'appending': 0.29; "skip:' 10": 0.30; 'subject:last': 0.30; 'helpful': 0.30; 'lists': 0.31; 'ordered': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'from:addr:googlemail.com': 0.35; 'received:209.85': 0.35; 'subject:" ': 0.36; 'does': 0.37; 'passed': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'received:209.85.214': 0.39; 'your': 0.60; 'matter': 0.61; 'first': 0.61; 'more': 0.63; 'within': 0.64; 'making': 0.64; 'believe': 0.69; 'received:209.85.214.184': 0.84; 'received:mail- ob0-f184.google.com': 0.84; 'realistic': 0.93
Newsgroups comp.lang.python
Date Fri, 28 Sep 2012 17:24:59 -0700 (PDT)
In-Reply-To <b3564f31-f54c-4c00-a6e7-f497911c054a@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw
References <7cd170ac-bb14-4baa-93ea-530c569d3985@googlegroups.com> <mailman.1587.1348875975.27098.python-list@python.org> <b3564f31-f54c-4c00-a6e7-f497911c054a@googlegroups.com>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 123.192.32.215
MIME-Version 1.0
Subject Re: creating an artificial "last element" in sort list
From 88888 Dihedral <dihedral88888@googlemail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc Python <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1590.1348878303.27098.python-list@python.org> (permalink)
Lines 72
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348878303 news.xs4all.nl 6870 [2001:888:2000:d::a6]:49276
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30438

Show key headers only | View raw


dave於 2012年9月29日星期六UTC+8上午7時51分10秒寫道:
> more clearer, this is a more realistic use case:
> 
> 
> 
> ['awefawef', 'awefawfsf', 'awefsdf', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz']
> 
> 
> 
> and the quantity of ''zzzzzzzzzzzzzz'' would be dynamic.
> 
> 
> 
> On Friday, September 28, 2012 4:46:15 PM UTC-7, Ian wrote:
> 
> 
> 
> > 
> 
> > > a = ['a', 'b', x]
> 
> > 
> 
> > >
> 
> > 
> 
> > > b = sorted(a)
> 
> > 
> 
> > >
> 
> > 
> 
> > > What does x need to be to always be last on an ascending sort no matter what 'a' and 'b' are.... within reason... I am expecting 'a' and 'b' will be not longer than 10 char's long.... I tried making x = 'zzzzzzzzzzzzzzzz' and believe it or not, this appears FIRST on the sort!!!
> 
> > 
> 
> > 
> 
> > 
> 
> > It appears last when I run the code.
> 
> > 
> 
> > 
> 
> > 
> 
> > To answer your question, though, if you want to force x to be last,
> 
> > 
> 
> > then I suggest removing it from the list and then appending it to the
> 
> > 
> 
> > end.

I am thinking if it is helpful to preprocess an arbitrary
list first into some set of unique  ordered elements before a sort. 

Anyway lists are passed by references  to functions in python. 

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


Thread

creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:39 -0700
  Re: creating an artificial "last element" in sort list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 17:45 -0600
    Re: creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:51 -0700
      Re: creating an artificial "last element" in sort list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-28 17:24 -0700
      Re: creating an artificial "last element" in sort list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-28 17:24 -0700
      Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:32 -0700
        Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:59 -0700
          Re: creating an artificial "last element" in sort list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 21:29 -0600
        Re: creating an artificial "last element" in sort list Demian Brecht <demianbrecht@gmail.com> - 2012-09-28 17:59 -0700
      Re: creating an artificial "last element" in sort list duncan smith <buzzard@invalid.invalid> - 2012-09-29 02:19 +0100
    Re: creating an artificial "last element" in sort list dave <davidreynon@gmail.com> - 2012-09-28 16:51 -0700
  Re: creating an artificial "last element" in sort list Paul Rubin <no.email@nospam.invalid> - 2012-09-28 18:42 -0700
  Re: creating an artificial "last element" in sort list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-29 02:05 +0000

csiph-web