#Sort Assignment
import random
import sys
import os

#Create the list, and create an empty list of the same size
original_list = [ 18, 24, 32, 55, 22, 4, 61 ]
sorted_list = [ 0,0,0,0,0,0,0]

#make a copy of the list to work with
wrk_list = list(original_list)

num_items = len(wrk_list)
print ("wrk_list has ",num_items," items")
wrk_list_index = 0
sorted_list_index = 0

max = 0

#Outer loop
while (sorted_list_index < num_items):
    #reset the list_index for the inner loop
    wrk_list_index = 0
    #reset the max value to 0
    max = 0

    #inner loop
    while (wrk_list_index < num_items):
        #if the next item is greater than max, set max = to that value
        if (wrk_list[wrk_list_index] > max):
            max = wrk_list[wrk_list_index]
            max_index = wrk_list_index # this is needed laterw
        #increase the index for this loop
        wrk_list_index = wrk_list_index + 1
    
    #put the max value found into the next cell of the sorted_list
    sorted_list[sorted_list_index] = max

    # increment the sorted_list_index by 1, for the next cycle of the loop
    sorted_list_index = sorted_list_index+1

    #replace the max value found in list with
    wrk_list[max_index] = 0

#show the results of the sort
print("The original list was: ",original_list)
print("the sorted list is    :",sorted_list)

#Python has a list sort function which sorts from lowest to highest
wrk_list = list(original_list)

wrk_list.sort()
print("\nThe Python sorted list is : ",wrk_list)

wrk_list.reverse()
print("This is the reversed list : ", wrk_list)


 
            
