Added selectionsort

This commit is contained in:
Martin Putzlocher 2022-05-02 07:00:51 +02:00
parent 96d79c4cae
commit 52ad9376fe

View File

@ -0,0 +1,15 @@
l = [12,124,1,31,51,4563,76,43,532,7,98,786,63,68,2,15,764,345,2,7,85]
def selectionsort(alist):
blist = alist[:] # work on a copy
result = list()
for i in range(len(blist)):
# find min element
min_e = min(blist)
result.append(min_e)
blist.remove(min_e)
print(result)
return result
sorted = selectionsort(l)
print(sorted)