Runtime check failure #2 - Stack around the variable "array" was corrupted.
Hi, in the if condition: if (myArray[index] > myArray[index + 1]) index+1 may be equal to end (when index take the value end-1) and it can't access to this element that doesn't exist
social.msdn.microsoft.com