Sort comprehensions? (Re: longest sequence)

Greg Ewing (using news.cis.dfn.de) me at privacy.net
Tue Feb 18 19:02:42 EST 2003


Tim Peters wrote:

> The difficulty is that, when comparing
> 
>     (n, seq1)
> to
>     (n, seq2)
> 
> the tie on n means seq1 gets compared to seq2 in order to try to break the
> tie.


Maybe list comprehensions should have a sorting clause:

   [x for x in stuff sortedby x.key]

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list