At first glance, there seems to be some problem with your Merge() method not merging all data
Assume merge is called with the following params:
Merge(array,0,1,1,2) <-- implies a 2-element array divided in two.
(SIDE NOTE: upper1 is always the same as lower2 so you don't need to pass it, in fact they are both derivived from lower1 and upper2, so they aren't needed at all for passing)
Watch what happens after one execution of the while loop:
lower1 goes from 0 --> 1
-or-
lower2 goes from 1 --> 2
And since lower1 >= upper1 ( 1 >= 1) -or- lower2 >= upper2 ( 2 >= 1) the loop will execute exactly once. But, there were two elements to be merged! Therefore, one element may be over-ridden. The common solution is that after your while loop
you should have two additional loops that copy missing data to the temp array from whichever array did not finish (if the loop terminates at least one array must be complete)
There may be more problems, but thats the only one that struct me right away. BTW note that you are cutting up the original array in some way since you are using a temporary array. Its not a true 'in-place' sort anyway.
[ December 04, 2005: Message edited by: Scott Selikoff ]