Python:Insertion sort

Though it’s a simple insertion sort program but it’s written in python.Recently i have started learning this language and it’s fantastic…i can’t resist myself from posting the programs. 🙂

a=[]
print "Enter 10 integers"
for i in range(10):
    x=int(raw_input(""))
    a.append(x)
for i in range(1,10):
    tmp=a[i]
    j=i-1;
    while tmp<a[j] and j>=0:
        a[j+1]=a[j]
        j=j-1
    a[j+1]=tmp

print "The sorted array is"
for i in range(10):
    print a[i]