This is just a personal project I'm working on, and have been working on it for days, looking at several Recursive Selection Sort functions online to help me accomplish this goal, but to no avail because the Recursive Selection Sort functions I've come across did not help. I would like to combine the two (2) Recursive functions below to create one (1) Recursive Selection Sort function, using a 'while loop' and the same variables as much as possible. Please provide the pseudo code; I'd like to try to figure it out from pseudo code to test the knowledge I've attained thus far in learning the Python programming language. Oh and, I'm aware of the Selection sorting shortcut, the sort() function, but I want to learn the long way as well in how to code functions, programs and processes. Thanks!
def searchMinFromList(L,n):
minValue = L[0]
idx = 0
counter = 1
while (counter < n):
v = L[counter]
if v < minValue:
minValue = v
idx = counter
else:
pass
counter += 1
return minValue, idx
def sortList(L,n):
L2 = []
counter = 0
while (counter < n):
m, idx = searchMinFromList(L,n)
L2.append(m)
del L[idx]
n-=1
return L2
L = [34, -1, 0, 89, 21, -40, 7]
n = len(L)
print(sortList(L, n))
def searchMinFromList(L,n):
minValue = L[0]
idx = 0
counter = 1
while (counter < n):
v = L[counter]
if v < minValue:
minValue = v
idx = counter
else:
pass
counter += 1
return minValue, idx
def sortList(L,n):
L2 = []
counter = 0
while (counter < n):
m, idx = searchMinFromList(L,n)
L2.append(m)
del L[idx]
n-=1
return L2
L = [34, -1, 0, 89, 21, -40, 7]
n = len(L)
print(sortList(L, n))