473,499 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1237
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2362
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
7
3231
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
4
9541
by: shyner | last post by:
Hi Everyone, I've been battling this for two days with no luck. I'm using SQL Server 2000. Here's the mystery: I've got a stored procedure that takes a single varchar parameter to determine...
1
1331
by: Kepler | last post by:
I'm fighting a really strange bug that involves both a DataGrid and a Repeater disappearing on postback. The strange thing is that I've distilled the problem down to a simple program, that...
11
2117
by: rkbnair | last post by:
I have created a datagrid in my aspx with the 'AllowSorting' property to true. When clicking on the column header, the page refreshes. However the sorting is not done. Am I missing anything? I...
4
1011
by: ^MisterJingo^ | last post by:
I am getting the following error: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error...
8
2186
by: sara | last post by:
Hi - I have looked at all posts and tried both Allen Browne's Report Sorting at run Time ( Select Case Forms!frmChooseSort!grpSort Case 1 'Name Me.GroupLevel(0).ControlSource = "LastName"...
7
2378
by: abracadabra | last post by:
I am reading an old book - Programming Pearls 2nd edition recently. It says, "Even though the general C++ program uses 50 times the memory and CPU time of the specialized C program, it requires...
7
1653
by: christery | last post by:
Anyone got a clue to why ther is a T between date and time in the "formatted for sorting" or whatewer they call it, and a Z at the end after seconds- got it fixed for my cobol programmer by...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.