This Python code gives sorted elements according to string elements.
How we convert list elements, which are in string format in integer type?
This is my code:
def insertionSort(arr, n):
for i in range(1, n):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j+1] = arr[j]
j = j - 1
arr[j+1] = key
print '\nSorted elements: ',
return (' ').join(arr)
arr = (raw_input("enter elements: ")).split(',')
print insertionSort(arr, len(arr))
int(arr[j]) > int(key)