mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Create seletction_sort.py
This commit is contained in:
parent
b068e60212
commit
e1805c9fb5
14
sorting/seletction_sort.py
Normal file
14
sorting/seletction_sort.py
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def selection_sort(lst):
|
||||
|
||||
for i in range(len(lst)):
|
||||
min_index = i
|
||||
for j in range(i + 1, len(lst)):
|
||||
if lst[j] < lst[min_index]:
|
||||
min_index = j
|
||||
|
||||
lst[min_index], lst[i] = lst[i], lst[min_index]
|
Loading…
x
Reference in New Issue
Block a user