Implementation of Insertion Sort using JavaScript:
- Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. Each time we take a new card, we put it in the right place in our hand.
- Work only with the first
i-1elements of the array. - Pick element
arr[i]and insert it into the sorted sequence in the array from0toi-1.