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 -- http://mail.python.org/mailman/listinfo/python-list