From: Skullheadx <704277@pdsb.net> Date: Wed, 25 Jan 2023 00:00:47 +0000 (-0500) Subject: Update selection_sort.py X-Git-Url: http://git.skullheadx.com/life/index.html?a=commitdiff_plain;h=482a7f8f17ba80cd54169068a382438743beee44;p=Sorting.git Update selection_sort.py --- diff --git a/sorting_algorithms/selection_sort.py b/sorting_algorithms/selection_sort.py index cff5ee3..99d7f54 100644 --- a/sorting_algorithms/selection_sort.py +++ b/sorting_algorithms/selection_sort.py @@ -3,7 +3,7 @@ from utils import swap def selection_sort(array): - for index1 in range(len(array) - 1, -1, -1): # loop through from end + for index1 in range(len(array) - 1, 0, -1): # loop through from end swap_index = 0 # largest element to swap with for index2 in range(index1 + 1): # loop through the first index1 elements if array[index2] > array[swap_index]: # find the max element to swap with