<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Leticia Larrosa wrote:
<blockquote
 cite="midWorldClient-F200504241736.AA36490608@tesla.cujae.edu.cu"
 type="cite">
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">Hi
all: </div>
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">
&nbsp;</div>
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">I
want to order a sequence using the Sequence sorting module from a
Python script. </div>
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">I
have the following code: <br>
"<br>
seq = [['Bruzon', 'CUB'], ['Anand', 'IND'], ['Kasparov', 'RUS']]<br>
def test(oneElem, twoElem):<br>
&nbsp;&nbsp;&nbsp; if oneElem[0] == twoElem[0]:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0<br>
&nbsp;&nbsp;&nbsp; elif oneElem[0] &gt; twoElem[0]:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1<br>
&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1</div>
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">
sort_on =(('self', test, 'desc'))<br>
return sequence.sort(seq, sort_on)<br>
"</div>
  <div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">
and i get the error:<br>
"<br>
Error Type: SyntaxError<br>
Error </div>
</blockquote>
<div
 style="font-size: 10pt; font-family: tahoma; background-color: white;">Value:
sort option must contains no more than 2 fields<br>
<br>
Leticia,<br>
I tested this using a python script in Zope - and it seems to work.&nbsp;
Nice to see someone doing something with Chess and Zope!<br>
<br>
</div>
def test(x,y):<br>
&nbsp;&nbsp;&nbsp; if x[0] == y[0]:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0<br>
&nbsp;&nbsp;&nbsp; elif x[0] &gt; y[0]:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1<br>
&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1<br>
<br>
request = container.REQUEST<br>
<br>
seq = [['Bruzon', 'CUB'], ['Anand', 'IND'], ['Kasparov', 'RUS']]<br>
<br>
seq.sort(test)<br>
print seq<br>
<br>
David<br>
</body>
</html>