Q: listsort and dictsort - official equivalents?
Delaney, Timothy (Tim)
tdelaney at avaya.com
Wed Jun 20 19:05:14 EDT 2007
Steve Howell wrote:
> I think Gabriel was making the point that the *input*
> to sorted() cannot be a generator, even thought
> sorted() itself could in theory be a generator with
> the right underlying implementation (e.g. heapsort).
Actually, the input to sorted() can be any iterable - sorted puts all the elements into a new list, sorts the new list, then returns the new (sorted) list.
This means you can't return any items until you've exhausted the input iterable - which is what Gabriel was really getting at. Because of the documented semantics, it also must return the entire list.
Tim Delaney
More information about the Python-list
mailing list