Sorted and reversed on huge dict ?

Paul Rubin http
Fri Nov 3 20:29:36 CET 2006


Fredrik Lundh <fredrik at pythonware.com> writes:
>      items = d.items()
>      items.sort(key=operator.itemgetter(1), reverse=True)
> 
> the items list would require a couple of megabytes for 150k dictionary
> entries, or so.  the key map needs some memory too, but the rest of
> the sort is done in place.

I think the OP's method avoided the key map.



More information about the Python-list mailing list