diff --git a/Aufgabe02.py b/Aufgabe02.py index 29b8f5b435a9de9721d19b45590ae0af87dff008..7ed07581b039c7f416c8d29a13c2c349ca69b842 100644 --- a/Aufgabe02.py +++ b/Aufgabe02.py @@ -28,7 +28,16 @@ def InsertionSort(array): sorted_array: a sorted copy of the array ''' - return + sorted_array = list(array) + + for i in range(1, len(array)): + for j in range(i, 1, -1): + if sorted_array[j] < sorted_array[j-1]: + sorted_array[j], sorted_array[j-1] = sorted_array[j-1], sorted_array[j] + else: + continue + + return sorted_array def CountingSort(array): '''Sort the array by counting the occurrence of each element in the array.