21.7.11

Python bubble sorting

#lst is a array list - lst=[[0,0,0],[0,1,0]...]
#it is the coordinates of the nodes. sorting according with x
def bubblesort(lst):
for i in range(len(lst)-1,0,-1):
for j in range(i):
if (lst[j][0]>lst[j+1][0]):
lst[j],lst[j+1]=lst[j+1],lst[j]

没有评论: