From 5b38a549a7cdd9c482765962d7270fa10fadf742 Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:42:21 -0700 Subject: [PATCH] Update seletction_sort.py --- sorting/seletction_sort.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sorting/seletction_sort.py b/sorting/seletction_sort.py index ccd601d..cecb99d 100644 --- a/sorting/seletction_sort.py +++ b/sorting/seletction_sort.py @@ -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]