Skip to content

Commit 326da83

Browse files
Video Derrick-Sherrill#2 Selection Sort
1 parent 88fbe9a commit 326da83

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

2-selection-sort.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
def selection_sort(list_a):
3+
indexing_length = range(0, len(list)-1)
4+
5+
for i in indexing_length:
6+
min_value = i
7+
8+
for j in range(i+1, len(list_a)):
9+
if list_a[j] < list_a[min_value]:
10+
min_value = j
11+
12+
if min_value != i:
13+
list_a[min_value], list_a[i] = list_a[i], list_a[min_value]
14+
15+
return list_a
16+
17+
print(selection_sort([6,7,8,7,6,5,4,5,6,7,6,7,8,9,7,9,0]))

0 commit comments

Comments
 (0)