selection sort logic code example
Example 1: selection sort
def ssort(lst):
for i in range(len(lst)):
for j in range(i+1,len(lst)):
if lst[i]>lst[j]:lst[j],lst[i]=lst[i],lst[j]
return lst
if __name__=='__main__':
lst=[int(i) for i in input('Enter the Numbers: ').split()]
print(ssort(lst))
Example 2: selection sort
procedure selection sort
list : array of items
n : size of list
for i = 1 to n - 1
min = i
for j = i+1 to n
if list[j] < list[min] then
min = j;
end if
end for
if indexMin != i then
swap list[min] and list[i]
end if
end for
end procedure