Hi, one question again that I could not find neither in the mailing list nor in the ZopeBook: I have a list of ZODB objects, collected by using objectValues. How can I sort this list by the id? is this SortEx? how can I access SortEx? from within python script? --- I think we dream so we don't have to be apart so long. If we're in each other's dreams, we can play together all night. -- Calvin --- Oliver Pabst .-------------------------. mailto:olpa@sybcom.de : : phone :+49 681 56600600 : project department : SYBCOM GmbH fax :+49 681 56600660 : : http://www.sybcom.de
On Tue, Oct 02, 2001 at 03:36:06PM +0200, olpa@sybcom.de wrote:
I have a list of ZODB objects, collected by using objectValues.
How can I sort this list by the id? is this SortEx? how can I access SortEx? from within python script?
Something like this: from DTML import SortEx # I am not sure if it is allowed return SortEx(mysequence, ((id,),)) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
How about: sorted_list = list.sort(lambda x, y: cmp(x.getId(), y.getId()) Where list is your list of objectValues. Mike ----- Original Message ----- From: <olpa@sybcom.de> To: <zope@zope.org> Sent: Tuesday, October 02, 2001 6:36 AM Subject: [Zope] Sorting of objectValues within python script
Hi, one question again that I could not find neither in the mailing list nor in the ZopeBook:
I have a list of ZODB objects, collected by using objectValues.
How can I sort this list by the id? is this SortEx? how can I access SortEx? from within python script?
--- I think we dream so we don't have to be apart so long. If we're in each other's dreams, we can play together all night. -- Calvin --- Oliver Pabst .-------------------------. mailto:olpa@sybcom.de : : phone :+49 681 56600600 : project department : SYBCOM GmbH fax :+49 681 56600660 : : http://www.sybcom.de
_______________________________________________ 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 )
On Today, Michael Murphy wrote:
Delivered-To: olpa@sybcom.de Subject: Re: [Zope] Sorting of objectValues within python script Date: Tue, 2 Oct 2001 08:01:02 -0700 To: olpa@sybcom.de, zope@zope.org From: Michael Murphy <mike@flipper.eskimo.net>
How about:
sorted_list = list.sort(lambda x, y: cmp(x.getId(), y.getId())
Where list is your list of objectValues.
that's it! but list.sort(blabla) does not return a list, but sorts the list itself! but that is ok. i really should look further into the lambda thing in python! Thank you! --- I think we dream so we don't have to be apart so long. If we're in each other's dreams, we can play together all night. -- Calvin --- Oliver Pabst .-------------------------. mailto:olpa@sybcom.de : : phone :+49 681 56600600 : project department : SYBCOM GmbH fax :+49 681 56600660 : : http://www.sybcom.de
participants (3)
-
Michael Murphy -
Oleg Broytmann -
olpa@sybcom.de