def selection(list1):
x=0
while(x<len(list1)):
small_index=x
for y in range(x+1,len(list1)):
if list1[y]<list1[small_index]:
small_index=y
list1[x],list1[small_index]=list1[small_index],list1[x]
x+=1
print "\nSorted list is : "
print list1
def main():
#Unsorted list
list1=[5,2,8,6,5,9,0,3,11,54,67,34]
selection(list1)
if __name__=='__main__':
main()
x=0
while(x<len(list1)):
small_index=x
for y in range(x+1,len(list1)):
if list1[y]<list1[small_index]:
small_index=y
list1[x],list1[small_index]=list1[small_index],list1[x]
x+=1
print "\nSorted list is : "
print list1
def main():
#Unsorted list
list1=[5,2,8,6,5,9,0,3,11,54,67,34]
selection(list1)
if __name__=='__main__':
main()
No comments:
Post a Comment