Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
arr = [40, 4, 20, 10, 30, 6, 10]

# insertion sort:
for i in range(1, len(arr)):
a_i = arr[i]
j = i - 1
while j >= 0:
print("comparing {} and {}".format(arr[j], a_i]))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wouldn't believe it, but it still doesn't work!!!

if arr[j] > a_i:
arr[j + 1] = arr[j]
else:
break
j -= 1
arr[j + 1] = a_i

print(arr)