Skip to content

Commit 86e95ee

Browse files
Add files via upload
1 parent 8f9f802 commit 86e95ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

insertsort.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def insert(arr):
2+
for i in range(len(arr)):
3+
tmp=arr[i]
4+
j=i-1
5+
while j>=0 and tmp<arr[j]:
6+
arr[j+1]=arr[j]
7+
j=j-1
8+
arr[j+1]=tmp
9+
return arr
10+
arr=[799,12,31,25,8,32,17]
11+
print('Before Sorting:',arr)
12+
ar=insert(arr)
13+
print('After Sorting:',ar)

0 commit comments

Comments
 (0)