newbie question
Wojtek Walczak
gminick at hacker.pl
Sat Dec 14 11:41:05 EST 2002
Dnia Sat, 14 Dec 2002 15:53:59 GMT, Classified napisał(a):
> a=[('a',1),('c',5),('k',5),('o',3), ('i',3)]
> for i in range(0, len(a)-1):
> for j in range(1, len(a)):
> if a[i][1]>a[j][1]:
> a[i],a[j]=a[j],a[i]
> print a
> it appears that the bubble sort will not sort a...
> I guess I must have made a stupid mistake somewhere...
How do you want it to work ?
ps. For me it returns that:
[('a', 1), ('c', 5), ('k', 5), ('o', 3), ('i', 3)] - before for loops
[('a', 1), ('k', 5), ('c', 5), ('o', 3), ('i', 3)] - after for loops
--
[ ] gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]
More information about the Python-list
mailing list