Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bash': 0.07; 'parsing': 0.07; 'terry': 0.09; 'cc:addr:python-list': 0.10; '-tkc': 0.16; 'crop': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'module': 0.19; 'sort': 0.21; 'tells': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'leave': 0.26; 'am,': 0.27; 'is?': 0.27; 'omitted': 0.29; 'file': 0.32; "won't": 0.35; 'subject:: ': 0.38; 'easily': 0.39; 'subject:, ': 0.61; 'treat': 0.65; 'received:50.22': 0.84; 'kat': 0.91; 'subject:skip:E 10': 0.95 Date: Tue, 17 Jul 2012 12:56:14 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Terry Reedy Subject: Re: Encapsulation, inheritance and polymorphism References: <3-WdnYTg0r6XyZjNnZ2dnUVZ7sidnZ2d@bt.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342547710 news.xs4all.nl 6964 [2001:888:2000:d::a6]:41462 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25522 On 07/17/12 12:24, Terry Reedy wrote: > On 7/17/2012 8:01 AM, Lipska the Kat wrote: >> In bash this is laughably trivial >> >> sort -nr $1 | head -${2:-10} > > Won't sort work alphabetically and leave the following as is? > > 1\talpha > 11\tbeta > 2\tgamma Only if Lipska had omitted the "-n" which tells sort to treat numbers like numbers. For Lipska, you'd want to look into the "csv" module for parsing the file easily (specifying '\t' as the delimiter). You can then sort and crop as-is, or you can use heapq.nsmallest() -tkc