Re: sort() method

Peter Dobcsanyi (peter@mat.aukuni.ac.nz)
16 Jul 1992 14:16:40 +1200 (NZST)

Jack Jansen writes:
> I don't think that having a built-in sort() with user-supplied compare
> routine would be a big win when compared to programming sort yourself.
> Calling out to the python code would probably loose you most of the
> performance that programming in C would win you.

To be more precise, I did not think of writing any external C (or
whatever else other language) routine. What I meant is something like
that:

def my_compare(x,y)
if x <my_less> y : return -1
if x <my_equal> y : return 0
if x <my_greater> y : return 1

......
# then I could say

foo_list.sort(my_compare)

> A generic sort module in python should be peanuts, though. Anyone feel
> like writing one?

Maybe this is the solution, but (being a beginner) I cannot see how can
one refine the *built-in* sort() method on Python level.

Could anyone, please, give some general idea about the mentioned
"peanuts".

-- 
           ,
Peter Dobcsanyi