Re: Q: listsort and dictsort - official equivalents?

2007-06-19 Thread Neville D
t 02:57 +0200, BJörn Lindqvist wrote: > You can even sort by the gid: > > for group in sorted(open("/etc/group"), key = lambda x: int(x.split(':')[2])): > print group, -- Neville D - NZ ᛭ᚾᛖ᛬​ᚡᛁᛚᛖ᛬​ᚡᛖᛚᛁᛋ᛭ᛖᛚᚪᛏᚢᛗ᛬​ᚪ᛬​ᛎᛖᚢᛋ᛬​ᚾᚰ᛬​ᛞᛖᛈᚱᛁᛗᚪᛏ᛭ note: This document contai

Q: listsort and dictsort - official equivalents?

2007-06-19 Thread Neville D
I expressed my creativity & created two routines, listsort & dictsort. def listsort(l,cmp=None): l.sort(cmp); return l def dictsort(d,cmp=None):return [(k,d[k])for k in listsort(d.keys(),cmp=cmp)] Basically I am more familiar with sorting inside a for loop, eg in bourne shell one can do "for lo