def selection_sort(arr):
for i in range(len(arr) - 1):
min_index = i
for j in range(i + 1, len(arr)):
if arr[j] arr[min_index]:
min_index = j
arr[i], arr[min_index] = arr[min_index], arr[i]
return arr

arr = [5, 6, 4, 7, 3, 8, 2, 9, 1, 0]
print("Sorted array is:", selection_sort(arr))

Output of the following python program is

Posted on by