Skip to content

Commit b1f2a22

Browse files
committed
SelectionSort.py finally approved
1 parent fe0db18 commit b1f2a22

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def selection_sort(unordered_list):
2+
size_of_list = len(unordered_list) - 1
3+
for i in range(size_of_list):
4+
small = i
5+
for j in range(i+1, size_of_list):
6+
if unordered_list[j] < unordered_list[small]:
7+
small = j
8+
temp = unordered_list[i]
9+
unordered_list[i] = unordered_list[small]
10+
unordered_list[small] = temp
11+
12+
13+
a_list = [3, 2, 35, 4, 32, 94, 5, 7]
14+
print("List before sorting", a_list)
15+
selection_sort(a_list)
16+
print("List after sorting", a_list)

0 commit comments

Comments
 (0)