Re: [Zope] Sequence sorting module from a Python script
Thanks to David and Andreas.! -Original Message- From: Andreas Jung <[EMAIL PROTECTED]> To: Leticia Larrosa <[EMAIL PROTECTED]>, zope@zope.org Date: Mon, 25 Apr 2005 05:30:12 +0200 Subject: Re: [Zope] Sequence sorting module from a Python script > > > --On Sonntag, 24. April 2005 17:36 Uhr -0400 Leticia Larrosa > <[EMAIL PROTECTED]> wrote: > > sort_on =(('self', test, 'desc')) > > As documented the 'sort_on_ parameter must be a *sequence* of sorting > definitions and a *single* sorting > definition. This should work: > > sort_on =(('self', test, 'desc'),) > > -aj ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Sequence sorting module from a Python script
--On Sonntag, 24. April 2005 17:36 Uhr -0400 Leticia Larrosa <[EMAIL PROTECTED]> wrote: sort_on =(('self', test, 'desc')) As documented the 'sort_on_ parameter must be a *sequence* of sorting definitions and a *single* sorting definition. This should work: sort_on =(('self', test, 'desc'),) -aj pgp51rKhSGV4U.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Sequence sorting module from a Python script
Leticia Larrosa wrote: Hi all: I want to order a sequence using the Sequence sorting module from a Python script. I have the following code: " seq = [['Bruzon', 'CUB'], ['Anand', 'IND'], ['Kasparov', 'RUS']] def test(oneElem, twoElem): if oneElem[0] == twoElem[0]: return 0 elif oneElem[0] > twoElem[0]: return 1 else: return -1 sort_on =(('self', test, 'desc')) return sequence.sort(seq, sort_on) " and i get the error: " Error Type: SyntaxError Error Value: sort option must contains no more than 2 fields Leticia, I tested this using a python script in Zope - and it seems to work. Nice to see someone doing something with Chess and Zope! def test(x,y): if x[0] == y[0]: return 0 elif x[0] > y[0]: return 1 else: return -1 request = container.REQUEST seq = [['Bruzon', 'CUB'], ['Anand', 'IND'], ['Kasparov', 'RUS']] seq.sort(test) print seq David ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )