[Tutor] I can't work out how to sort lists of lists

Phil Bertram phil.bertram@clear.net.nz
Tue, 20 Mar 2001 09:23:44 +1200


This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C0B11F.75CF0D20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

I have a list thus,

a=3D[  (8,9,10), (1,2,3), (5,6,7)  ]=20

I wish to sort the list by the second element of each tuple.

I can not seem to work out how to get the sort method's compare function =
to work.

Any ideas ?

Thanks in advance

Phil B

------=_NextPart_000_0008_01C0B11F.75CF0D20
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi all,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I have a list thus,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>a=3D[&nbsp;&nbsp;(8,9,10), (1,2,3), (5,6,7)&nbsp;=20
]&nbsp;</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I wish to sort the list by the second element of =
each=20
tuple.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I can not seem to work out how to get the sort =
method's=20
compare function to work.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any ideas ?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Thanks in advance</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Phil B</FONT></DIV></BODY></HTML>

------=_NextPart_000_0008_01C0B11F.75CF0D20--