Regarding sort()

Jaime Fernandez del Rio jaime.frio at gmail.com
Mon May 25 05:44:02 EDT 2009


On Mon, May 25, 2009 at 10:15 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> Erm, using a compare function rather than a key function slows down
> sorting /significantly/. In fact, the `cmp` parameter to list.sort()
> has been *removed* in Python 3.0 because of this.

Makes a lot of sense, as you only have to run the slow python function
N times, rather than doing it N log N times...

So I guess I have also learned today that the internal cmp can handle
lists and tuples properly, i.e (1,7) > (1,5), definitely a much neater
way of doing things: the reasons are starting to pile to fare 2.6
goodbye and move on to 3.0...

>
> Also, top-posting is evil. Please avoid it in the future.

Must be the mad scientist wanting to take over the world in me. ;-)

Note taken...

Jaime

>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.



More information about the Python-list mailing list