with inbuilt functions :
list1=[1,2,3]
list1.sort()
without inbuilt functions :
def sortlist(list):
for i in range(len(list)):
for j in range(len(list) - 1):
if list[j] > list[j+1]:
t=list[j]
list[j]=list[j+1]
list[j+1]=t
list1=[2,12,1,21,2,12,1,2]
sortlist(list1)
print list1
list1=[1,2,3]
list1.sort()
without inbuilt functions :
def sortlist(list):
for i in range(len(list)):
for j in range(len(list) - 1):
if list[j] > list[j+1]:
t=list[j]
list[j]=list[j+1]
list[j+1]=t
list1=[2,12,1,21,2,12,1,2]
sortlist(list1)
print list1
No comments:
Post a Comment