How to get a directory list sorted by date?

Chris Angelico rosuav at gmail.com
Sun May 15 17:52:19 EDT 2016


On Mon, May 16, 2016 at 2:00 AM, Grant Edwards
<grant.b.edwards at gmail.com> wrote:
> On 2016-05-15, Michael Selik <michael.selik at gmail.com> wrote:
>> On Sun, May 15, 2016, 10:37 AM Grant Edwards <grant.b.edwards at gmail.com> wrote:
>>> On 2016-05-15, Tim Chase <python.list at tim.thechases.com> wrote:
>>>>
>>>> unless sorted() returns a lazy sorter,
>>>
>>> What's a lazy sorter?
>>
>> One that doesn't calculate the next item in the sequence until you
>> ask for it. It's impossible
>
> Why?  As long as the function has access to the entire sequence, it
> should be trivial.  Just find the min (or max) item in the sequence,
> remove it, then return it.  It's horribly inefficient, but...
>
>> unless you don't mind an approximation rather than correct sort.
>
> I have a feeling that I've missed the joke somewhere.

Sure, it's not impossible to implement, but generally the point of
lazy generation is that it's more efficient. Going from O(N log N)
with O(N) memory to O(N*N) with O(1) memory is not usually what you
want!

ChrisA



More information about the Python-list mailing list