insertion sort we take an unsorted array for our example insertion sort compares the first two elements it finds that both and are already in ascending order for now is in sorted sub-list insertion sort moves ahead and compares with and finds that is not in the correct position it swaps with it also checks with all the elements of sorted sub-list here we see that the sorted sub-list has only one element and is greater than hencethe sorted sub-list remains sorted after swapping by now we have and in the sorted sub-list nextit compares with these values are not in sorted order so we swap them howeverswapping makes and unsorted