[Tutor] sorting a list of dictionaries
Larry Holish
ljholish at speakeasy.net
Thu Dec 9 23:39:56 CET 2004
On Thu, Dec 09, 2004 at 03:22:29PM -0500, Kent Johnson wrote:
> Using sort() with a user compare function is not recommended when you
> care about performance. The problem is that the sort function has to
> call back into Python code for every compare, of which there are many.
> The decorate - sort - undecorate idiom is the preferred way to do this
> in Python < 2.4. Python 2.4 adds the key= parameter to sort() and
> does the DSU internally.
Karl, Kent, thanks for your prompt responses. I'm running python 2.3,
and the DSU method performs nicely.
Regards,
Larry
--
Larry Holish
<ljholish at speakeasy.net>
More information about the Tutor
mailing list