list.sort(): heaviest item?

2008-04-08 Thread Steven Clark
If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html Most other types compare unequal unless they are the same object; the choice whether one

Re: list.sort(): heaviest item?

2008-04-08 Thread Diez B. Roggisch
Steven Clark wrote: If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html Most other types compare unequal unless they are the same

Re: list.sort(): heaviest item?

2008-04-08 Thread Steven Clark
You can pass a cmp-function that will always make one object being greater than all others. Diez -- Yeah, I figured it out 2 minutes after I posted, d'oh! class Anvil(object): def __cmp__(self. other): return 1 Sorry for the wasted space. --

Re: list.sort(): heaviest item?

2008-04-08 Thread Jeffrey Froman
Steven Clark wrote: If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? snip doc excerpt It looks like None always ends up at the start (lightest), but I want the opposite (heaviest). I don't know

Re: list.sort(): heaviest item?

2008-04-08 Thread Raymond Hettinger
On Apr 8, 8:15 am, Steven Clark [EMAIL PROTECTED] wrote: If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? Since the other guys gave you the real answer, how about this: sentinel = object()