def insertsort( arr ):
n = len( arr )
for i in range(1, n):
temp = arr[i]
j = i - 1
while j >= 0 and arr[j] > temp:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = temp
def main():
arr = [9,8,7,6,5]
print(arr)
insertsort(arr)
print(arr)
main()
ZGVmIGluc2VydHNvcnQoIGFyciApOgoKICAgIG4gPSBsZW4oIGFyciApCgogICAgZm9yIGkgaW4gcmFuZ2UoMSwgbik6CgogICAgICAgIHRlbXAgPSBhcnJbaV0KCiAgICAgICAgaiA9IGkgLSAxCgogICAgICAgIHdoaWxlIGogPj0gMCBhbmQgYXJyW2pdID4gdGVtcDoKCiAgICAgICAgICAgICAgYXJyW2orMV0gPSBhcnJbal0KCiAgICAgICAgICAgICAgaiAtPSAxCgogICAgICAgIGFycltqKzFdID0gdGVtcCAgICAgIAoKCmRlZiBtYWluKCk6CgogICAgYXJyID0gWzksOCw3LDYsNV0KCiAgICBwcmludChhcnIpCgogICAgaW5zZXJ0c29ydChhcnIpCgogICAgcHJpbnQoYXJyKQoKbWFpbigpCg==
[9, 8, 7, 6, 5]
[5, 6, 7, 8, 9]