Question: Solve in Python, please. In the code below, the selection-sort function repeatedly finds the smallest number in the current list and swaps it with the
Solve in Python, please.
In the code below, the selection-sort function repeatedly finds the smallest number in the current list and swaps it with the first one. Rewrite this program by finding the largest number and swapping it with the last one. Write a test program that reads in numbers entered in one line, invokes the function, and displays the sorted numbers.
THE CODE IS COPIED BELOW BUT PLEASE POST ONE WITH THE INDENTATIONS AND A TEST RUN. THANK YOU!

def selectionSort(lst):
for i in range(len(lst) - 1):
# Find the minimum in the lst[i : len(lst)]
currentMin = min(lst[i : ])
currentMinIndex = i + lst[i: ].index(currentMin)
# Swap lst[i] with lst[currentMinIndex] if necessary
if currentMinIndex != i:
lst[currentMinIndex], lst[i] = lst[i], currentMin
def main():
lst = [-2, 4.5, 5, 1, 2, -3.3]
selectionSort(lst)
print(lst)
main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
