list.sort(): heaviest item?

Raymond Hettinger python at rcn.com
Tue Apr 8 15:25:34 EDT 2008


On Apr 8, 8:15 am, "Steven Clark" <steven.p.cl... at gmail.com> 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()
mylist.sort()
mylist.append(sentinel)

_ ~
@ @
\_/




More information about the Python-list mailing list