diff --git a/algorithmen/selectionsort.py b/algorithmen/selectionsort.py new file mode 100644 index 0000000..9a19da0 --- /dev/null +++ b/algorithmen/selectionsort.py @@ -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)