Q: listsort and dictsort - official equivalents?

BJörn Lindqvist bjourne at gmail.com
Wed Jun 20 13:48:46 CEST 2007

On 6/20/07, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
> > It's not true that the sort must complete (or that the whole file must
> > be read for that matter), Python has cool generators which makes the
> > above possible.
> That's not possible, the input must be read completely before sorted() can
> output anything. Suppose the minimum element is at the end - until you
> read it, you can't output the very first sorted element.

Doh! Yes of course. I always thought that sorted() returned a
generator. Since Python's sort is based on merge sort, using a
generator approach it should at least be theoretically possible to
begin emitting the items before the sort operation completes.

mvh Björn

More information about the Python-list mailing list