Skip to content

Commit

Permalink
Merge branch 'sorting'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Rudometova committed Oct 5, 2024
2 parents 6dda55f + 3b1c0d4 commit 85c5651
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
arr = [40, 4, 20, 10, 30, 6, 10]

# selection sort:
for i in range(len(arr) - 1):
min = i
for j in range(i + 1, len(arr)):
print("comparing {} and {}".format(arr[j], arr[min]))
if arr[j] < arr[min]:
min = j
arr[i], arr[min] = arr[min], arr[i]

print(arr)

0 comments on commit 85c5651

Please sign in to comment.