From 981ad23e853f64f84721f1b874b97c415b35527d Mon Sep 17 00:00:00 2001 From: kmk028 Date: Sun, 7 Jun 2020 19:07:24 -0700 Subject: [PATCH] Bubble and selection sort complete --- src/iterative_sorting/iterative_sorting.py | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/iterative_sorting/iterative_sorting.py b/src/iterative_sorting/iterative_sorting.py index e27496b3..c3127bfb 100644 --- a/src/iterative_sorting/iterative_sorting.py +++ b/src/iterative_sorting/iterative_sorting.py @@ -6,21 +6,29 @@ def selection_sort( arr ): smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) - - - - + for j in range (cur_index+1,len(arr)): + #compare all values to value of curr index + # find the smallest + if arr[j]arr[j]: + arr[i],arr[j]=arr[j],arr[i] + made_a_swap=True + return arr