Python Program to Implement Selection Sorting

01. Example:

def selectionSorting(data):
    for i in range(0, len(data) - 1):
        smallest = i
        for j in range(i + 1, len(data)):
            if data[j] < data[smallest]:
                smallest = j
        data[i], data[smallest] = data[smallest], data[i]
 
 
list01 = input('Enter The List Of Numbers: ').split()
list01 = [int(x) for x in list01]

selectionSorting(list01)

print('nSorted list: ', end='')
print(list01)

Output:

Enter the list of numbers: 320 420 140 500 185 60 200 80 10 100
Sorted list: [10, 60, 80, 100, 140, 185, 200, 320, 420, 500]

 

Leave a comment