]> Skullheadx's Git Forge - Sorting.git/commitdiff
Update selection_sort.py
authorSkullheadx <704277@pdsb.net>
Wed, 25 Jan 2023 00:00:47 +0000 (19:00 -0500)
committerSkullheadx <704277@pdsb.net>
Wed, 25 Jan 2023 00:00:47 +0000 (19:00 -0500)
sorting_algorithms/selection_sort.py

index cff5ee3fd1d1d1ca5d2f9e71442e22b6b6786a28..99d7f54c0eb6a879782f08c87ecd08714ca86519 100644 (file)
@@ -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