468,287 Members | 2,010 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,287 developers. It's quick & easy.

Strange sorting error message

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:
>>myList.sort()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "[listModulePath]", line 239, in sort
self.listOfObjects.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.

Oct 3 '06 #1
10 1057
Dustan schrieb:
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:
>>>myList.sort()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "[listModulePath]", line 239, in sort
self.listOfObjects.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?

Diez

Oct 3 '06 #2

Diez B. Roggisch wrote:
Dustan schrieb:
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:
>>myList.sort()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "[listModulePath]", line 239, in sort
self.listOfObjects.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?
Whoops, I had created the variable returnValue in __cmp__, but
forgotten to return it. Now it works.

That was a dumb mistake; sorry for the trouble.

Oct 3 '06 #3
Dustan wrote:
I'm hiding some of the details here, because I don't want to say what
I'm actually doing.
[...]
I have the answer to your problem but I don't actually want to tell you
what it is.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Oct 4 '06 #4

Steve Holden wrote:
Dustan wrote:
I'm hiding some of the details here, because I don't want to say what
I'm actually doing.
[...]

I have the answer to your problem but I don't actually want to tell you
what it is.
That's great, seeing as I already figured out the answer, as I have
already posted in a reply.

Are you saying I broke one of these rules?
http://www.catb.org/~esr/faqs/smart-questions.html
Or are you just being plain rude?
A lack of a response from you implies the latter...
>
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Oct 5 '06 #5
On 2006-10-05, Dustan <Du**********@gmail.comwrote:
>
Steve Holden wrote:
>Dustan wrote:
I'm hiding some of the details here, because I don't want to
say what I'm actually doing.
[...]

I have the answer to your problem but I don't actually want to
tell you what it is.

That's great, seeing as I already figured out the answer, as I
have already posted in a reply.
I had a good laugh at it.
Are you saying I broke one of these rules?
http://www.catb.org/~esr/faqs/smart-questions.html
Or are you just being plain rude?
A lack of a response from you implies the latter...
SPOILER SPACE

It was a joke, based on you hiding what you are doing, he decided
to hide the solution to your problem. Get it?

--
Neil Cerutti
Oct 5 '06 #6

Neil Cerutti wrote:
On 2006-10-05, Dustan <Du**********@gmail.comwrote:

Steve Holden wrote:
Dustan wrote:
I'm hiding some of the details here, because I don't want to
say what I'm actually doing.
[...]

I have the answer to your problem but I don't actually want to
tell you what it is.
That's great, seeing as I already figured out the answer, as I
have already posted in a reply.

I had a good laugh at it.
Are you saying I broke one of these rules?
http://www.catb.org/~esr/faqs/smart-questions.html
Or are you just being plain rude?
A lack of a response from you implies the latter...

SPOILER SPACE

It was a joke, based on you hiding what you are doing, he decided
to hide the solution to your problem. Get it?
Ah, now I get it... Well, not really. I'm not outgoing, so it's hard
for me to spot a joke when I see one.
>
--
Neil Cerutti
Oct 5 '06 #7
Dustan wrote:
Neil Cerutti wrote:
>>On 2006-10-05, Dustan <Du**********@gmail.comwrote:
>>>Steve Holden wrote:

Dustan wrote:

>I'm hiding some of the details here, because I don't want to
>say what I'm actually doing.
>[...]

I have the answer to your problem but I don't actually want to
tell you what it is.

That's great, seeing as I already figured out the answer, as I
have already posted in a reply.

I had a good laugh at it.

>>>Are you saying I broke one of these rules?
http://www.catb.org/~esr/faqs/smart-questions.html
Or are you just being plain rude?
A lack of a response from you implies the latter...

SPOILER SPACE

It was a joke, based on you hiding what you are doing, he decided
to hide the solution to your problem. Get it?


Ah, now I get it... Well, not really. I'm not outgoing, so it's hard
for me to spot a joke when I see one.
Even when it smacks you in the face, apparently. Anyway, I'm sorry if
you thought I was getting at you in any way. Just trying to amuse the
group ...

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Oct 6 '06 #8
Steve Holden wrote:
Even when it smacks you in the face, apparently. Anyway, I'm sorry if
you thought I was getting at you in any way. Just trying to amuse the
group ...
time to reinstate mandatory use of the <winktag ?

</F>

Oct 6 '06 #9
On 10/5/06, Neil Cerutti <ho*****@yahoo.comwrote:
It was a joke, based on you hiding what you are doing, he decided
to hide the solution to your problem. Get it?
What if it was for a proprietary software of some kind?

-- Theerasak
Oct 6 '06 #10
On 2006-10-06, hanumizzle <ha********@gmail.comwrote:
On 10/5/06, Neil Cerutti <ho*****@yahoo.comwrote:
>It was a joke, based on you hiding what you are doing, he decided
to hide the solution to your problem. Get it?

What if it was for a proprietary software of some kind?
It wasn't sufficiently clear, hence the mild ribbing.

--
Neil Cerutti
The Rev. Merriwether spoke briefly, much to the delight of the
audience. --Church Bulletin Blooper
Oct 6 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by pmud | last post: by
7 posts views Thread by Federico G. Babelis | last post: by
11 posts views Thread by rkbnair | last post: by
4 posts views Thread by ^MisterJingo^ | last post: by
8 posts views Thread by sara | last post: by
7 posts views Thread by abracadabra | last post: by
7 posts views Thread by christery | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.