Qvault.io – Coding courses to launch your tech career Insertion sort is a simple algorithm that works just like you would arrange playing cards in your hands. A slice is first split into sorted and unsorted sections, then values from the unsorted section are inserted into the correct position in the sorted section.

The job of the inner for loop is to consume one value for each repetition, and grow the sorted output list, which are all the elements before index i.

Insertion sort is better for very small lists than some of the faster algorithms because: Ready to take action and get coding?

Related Articles