Selection Sort in Python

Python code to Implement Selection Sort. This Algorithm is very simple. Find the smallest element in the array and swap it. That's all you will get a sorted list at the end.

Source code :


array = [1,45,10,35,100,13,147,500,80]
size = len(array)


for i in range(0,size):
    for j in range(i+1,size):
        if array[j] < array[i]:
            min = array[j];
            array[j] = array[i];
            array[i] = min;



print(array)

Output :

[1, 10, 13, 35, 45, 80, 100, 147, 500]

Output :


                

Comments :