mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-22 16:31:15 -04:00
Update seletction_sort.py
This commit is contained in:
parent
1f23338150
commit
5b38a549a7
1 changed files with 7 additions and 6 deletions
|
@ -1,14 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def selection_sort(lst):
|
||||
|
||||
for i in range(len(lst)):
|
||||
def selection_sort(array):
|
||||
|
||||
for i in range(len(array)):
|
||||
min_index = i
|
||||
for j in range(i + 1, len(lst)):
|
||||
if lst[j] < lst[min_index]:
|
||||
|
||||
for j in range(i + 1, len(array)):
|
||||
if array[j] < array[min_index]:
|
||||
min_index = j
|
||||
|
||||
lst[min_index], lst[i] = lst[i], lst[min_index]
|
||||
array[min_index], array[i] = array[i], array[min_index]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue