I found a nice quick sort that doesn't need it
here it is (could you change the title to say general shell and quick sorts)
//general quicksort just pass the name of the array and the array size
//this is modified from http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Sort/Quick/ to work with verge
void quicksort(string array_name, int array_size)
{
quick(array_name, 0, array_size);
}
void quick(string array_name, int lo, int hi)
{
int leftp, rightp, median, temp;
if( hi > lo ) /* i.e. at least 2 elements, then */
{
leftp=lo;
rightp=hi;
median=GetIntArray(array_name, lo); /* NB. just an estimate! */
while(rightp >= leftp)
{
while(GetIntArray(array_name, leftp) < median)
leftp++;
while(GetIntArray(array_name, rightp) > median)
rightp--;
if(leftp <= rightp){
//swap:
temp=GetIntArray(array_name, leftp);
SetIntArray(array_name, leftp ,GetIntArray(array_name, rightp));
SetIntArray(array_name, rightp, temp);
leftp++;
rightp--;
}
}
quick(array_name, lo, rightp);// divide and conquer
quick(array_name, leftp, hi);
}
}