<aside> 💡 An almost-ordered may use this one (Ordered Insertion)

</aside>

Ordered Insertion


Using a almost ordered collection, we compare side-to-side elements changing their places because the other elements are already where they should be.

When to stop?

When the element reaches the first position or when it’s bigger than the one right before it.

Insertion Sort


Repeat it until the whole list is ordered

Going from the ordered insertion idea, the insertion sort algorithm orders any list (partially sorted or not).

It goes backwards


You get the last element the compares it to the ones before them.

Stop it when the element is lower than the one before


Or when the element is at the first position, obviously….

Stable