Insertion Sort is a simple Algorithm that compares the next element with the previous and swaps whenever the first element is greater than the second.
Javascript Example:
function insertionSort(array) {
for (let i = 1; i <= array.length - 1; i++) {
let j = i;
while (j > 0 && array[j - 1] > array[j]) {
[array[j - 1], array[j]] = [array[j], array[j - 1]];
j -= 1;
}
}
return array;
}