Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions selection sort
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
x = int(input("enter num of elem: "))
l=[]
for i in range(x):
b=int(input("enter elements: "))
a = l.append(b)
i = 0
while i<len(a):
#smallest element in the sublist
smallest = min(a[i:])
#index of smallest element
index_of_smallest = a.index(smallest)
#swapping
a[i],a[index_of_smallest] = a[index_of_smallest],a[i]
i=i+1
print (a)