#Selection Sort (Repeatedly find the minimum of a smaller sublist)

import random

def selection_sort(xlist):

    n = len(xlist)     # indices are 0,1,2,3, ..... , n-1.

    for i in range(0, n):
        
        nextmin = xlist[i]

        for j in range(i+1, n):

            if (xlist[j] < nextmin):

                #swap
                nextmin = xlist[j]
                xlist[j] = xlist[i]
                xlist[i] = nextmin

    return(xlist)


def main():

    n = 10

    zlist = []

    for j in range(0,n):

        zlist.append(random.randrange(1,100));


    print(zlist)
    
    s = selection_sort(zlist)

    print(s)


main()



        
