I've seen this and I would say we have a bug. It seems that when you use a method to sort on, what happens is that the method is not called, it is simply sorting on the reference of the method. Which is almost the same as not sorting at all ;). The reference I'm talking about is the <function a at 00895D74>, string when doing a __repr__ of a method/function. I hope I'm wrong here but I can't find any explanation for the behaviour. Any thoughts? Phil On Mon, 11 Nov 2002 11:19:03 -0500 "Jim Kutter" <zope-list@ebizq.net> wrote:
Thanks, but still no luck. What method name should I provide?
I tried datetime.millis, datetime, and datetime.timeTime (all with no (), I was just passing the reference)
-jim ----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: "Jim Kutter" <zope-list@ebizq.net> Cc: <zope@zope.org> Sent: Friday, November 08, 2002 5:11 PM Subject: Re: [Zope] Sort DateTime objects?
Jim Kutter writes:
I have a product with a class that contains a DateTime object with the name datetime (I know, bad choice, but the choice has been made...)
So I want to sort a collection of these objects by ascending date. So I get all objects of that type into a list called "events" then use the sequence module
So this is my basic logic - sorted = sequence.sort(events, (('datetime.x()', 'cmp', 'asc'),)) ^^^^^^^^^^^^ This must be the name of an attribute or parameterless method, not the method call itself. Use "x" alone.
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )