Program to sort a list of given numbers

Hello Guys! Welcome again to this amazing platform of Rickblog where we bring to you amazing wonders of the programming world and today I(a new joinee😁) will be taking you to a tour of sorting(not your life😥! Only elements).
#Sorting elements
alist=[15, 6,13,22 , 3,52,2]
print("Original list is:", alist)
for i in range(1, length(alist)) :
key=alist[i]
j=i-1
while j>0 and key<alist[j]:
alist[j+1]=alist[j]
j=j-1
else:
alist[j+1]=key
print("List after sorting:", alist)
Snapping out of code!!!! -Adiew.
Comments
Post a Comment