[Tutor] sorting into lists

Magnus Lycka magnus@thinkware.se
Sat, 21 Sep 2002 12:02:32 +0200


At 23:32 2002-09-20 -0500, Tim Wilson wrote:
>etc. The reason I need the list of lists is because it's the most
>obvious way I can think of to iterate over the events and print the date
>at the beginning of each inner loop. (Think nested for loops.)

Think again! :)

oldDate =3D None

for element in straightList:
     date =3D getDate(element) # you figure it out
     if date !=3D oldDate:
         print date
         oldDate =3D date
     print detailsToPrint(element)

Why make it more complicated than that?


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se