Skip to content

Commit 3a2d6d7

Browse files
committed
selection
1 parent be78520 commit 3a2d6d7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

selection_sort.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def selection_sort(L):
2+
for i in range(len(L)):
3+
min_indx = i
4+
5+
for j in range(i+1, len(L)):
6+
if L[min_indx] > L[j]:
7+
min_indx = j
8+
L[i], L[min_indx] = L[min_indx], L[i]
9+
10+
return L
11+
12+
L = [5,4,6,9,2,1]
13+
sort = selection_sort(L)
14+
print(sort)

0 commit comments

Comments
 (0)