Your implementation of insertion sort is bad.
In your inner loop, you should not scan all the way to i-1 , replacing each element more than ioList[i] . Instead, you should scan back from i-1 until you find the right place to insert a new element (that is, until you find an element that is less than or equal to the new element) and paste it there. If the input is already sorted, then the correct insertion point will always be found immediately, and therefore the inner loop does not execute i-1 times, it runs only once.
Your sort is also worse than sorting the insert on average, because you always perform i+1 operations for each iteration of the outer loop - some of these operating systems are just a match, and some are the result of a comparison, followed by a swap. Insertion sorting should be performed on average by half, as for random / average input, the correct insertion point is halfway through the initial sorted segment. Swaps can also be avoided, so each operation is a comparison plus a copy.
source share