Checks every element in the array. If the element to the left is smaller, then continuously swap until there is nothing smaller.
Python Implementation
def insertionsort(L) -> None:
for i in range(len(L))
value = L[i]
j = i
while j != 0 and L[j - a] > value:
L[j] = L[j-1]
j=j-1
L[j] = value
C Implementation
void insert_sort(int *arr, int size){
for (int i = 1 ; i < size; i++){
for (int j = i; j > 0; j--){
if (arr[j] < arr[j-1]){
int cpy = arr[j];
arr[j] = arr[j-1];
arr[j-1] = cpy;
}
}
}
}