<!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;">
</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>
if oneElem[0] == twoElem[0]:<br>
return 0<br>
elif oneElem[0] > twoElem[0]:<br>
return 1<br>
else:<br>
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.
Nice to see someone doing something with Chess and Zope!<br>
<br>
</div>
def test(x,y):<br>
if x[0] == y[0]:<br>
return 0<br>
elif x[0] > y[0]:<br>
return 1<br>
else:<br>
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>