Insertion Sort
Array
   Step-by-Step Animation   Animation Speed 
Elaboration:
?
Insertion Sort: This algorithm sorts in O(n2) where n is the size of the input array/vector.
The algorithm is fully explained and 3 variants are covered here. The following code is modeled after the second variant:
Given:
Array v of n values to be sorted
Method:
for(i = 1; i < v.size; i++) {
  tmp = v[i];
  for(j = i; j >= 1 && tmp < v[j - 1]; j--){
    v[j] = v[j - 1];
  }
  v[j] = tmp;
}
          
Insertion Sort: This algorithm sorts in O(n2) where n is the size of the input array/vector.
The algorithm is fully explained and 3 variants are covered here. The following code is modeled after the second variant:
Given:
Array v of n values to be sorted
Method:
for(i = 1; i < v.size; i++) {
  tmp = v[i];
  for(j = i; j >= 1 && tmp < v[j - 1]; j--){
    v[j] = v[j - 1];
  }
  v[j] = tmp;
}