Strange sorting error message
Diez B. Roggisch
deets at nospam.web.de
Wed Oct 4 00:40:40 CEST 2006
> I'm hiding some of the details here, because I don't want to say what
> I'm actually doing.
> I have a special-purpose class with a __cmp__ method all set up and
> ready to go for sorting. Then I have a special class that is based on
> the builtin type list (though I didn't actually inherit list; I
> probably should). When I create an instance with 2 or more items, and
> attempt to sort it, I get this strange error message:
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> File "[listModulePath]", line 239, in sort
> TypeError: an integer is required
> The sort method's code is exactly what you see; it's a one-line method.
> The only thing I can think of is the __cmp__ method is returning
> something other than an integer, which it's not.
Does stuffing the objects in a standard list and sorting them work? How
does the __cmp__-method look like?
More information about the Python-list