Your inner loop should start at arraySize - 1 to avoid an out of bounds array access, and end at i rather than 0. Currently by going all of the way to 0, you're undoing work done previously and messing up the result.

Your inner loop should start at arraySize - 1 to avoid an out of bounds array access, and end at i rather than 0. Currently by going all of the way to 0, you're undoing work done previously and messing up the result.