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
"
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)
"
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
"
and Traceback:
"
Traceback (innermost last):
Module ZPublisher.Publish, line 101, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.Scripts.Bindings, line 306, in __call__
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 323, in _exec
Module None, line 21, in orderBy
-
- Line 21
Module DocumentTemplate.sequence.SortEx, line 66, in sort
Module DocumentTemplate.sequence.SortEx, line 161, in make_sortfunctions
SyntaxError: sort option must contains no more than 2 fields
"
"
Error Type: SyntaxError
Error Value: sort option must contains no more than 2 fields
"
and Traceback:
"
Traceback (innermost last):
Module ZPublisher.Publish, line 101, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.Scripts.Bindings, line 306, in __call__
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 323, in _exec
Module None, line 21, in orderBy
-
- Line 21
Module DocumentTemplate.sequence.SortEx, line 66, in sort
Module DocumentTemplate.sequence.SortEx, line 161, in make_sortfunctions
SyntaxError: sort option must contains no more than 2 fields
"
what i'm doing wrong?
any suggestion?
Thanks in advance.
_______________________________________________ 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 )