I know the difference between insertion sort and shell sort. Insertion sort compares every single item with all the rest elements of the list, whereas shell sort uses a gap to compare items far apart from each other, and then recursively closes in the gap until all elements are sorted. Obviously, shell sort is more effective when the array items are shuffled far apart from their original order. However, when we have an array which is almost sorted, it seems the insertion sort algorithm will be more efficient. So if I want to use insertion sort or shell sort dependent on the situation, do I need to implement my own insertion sort and shell sort like this:
Code: