Skip to content

Arrays: Sort ascending

Task: Sort this array in ascending order

01234817233542SETTLED42index 4 is final

What you are watching

Sorting puts the values in ascending order by repeatedly finding the smallest one left and moving it to the front of what is unsorted. Each pass scans the remaining values, remembers where the smallest sat, and swaps it into place once. The green region on the left is finished and never has to be looked at again.