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
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
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.
--
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
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()