- Joined
- Jun 29, 2022

- Messages
- 14

- Reaction score
- 0

C++:

```
if (high!=low&& high>low)//compares hashes and finds the number in the middle. swaps hashes and corresponding words
{
long one=hash[low];
long two=hash[high];
long three = hash[high/2];
if((one<=two&&one>=three)||(one<=three&&one>=two))
{
swap(hash[low], hash[high]);
swap(copyOfWords[low], copyOfWords[high]);
}
else if((three<=one&&three>=two)||(three<=two&&three>=one))
{
swap(hash[high/2], hash[high]);
swap(copyOfWords[high/2], copyOfWords[high]);
}
else
{
}
int i=low;
int j=high-1;
while(i!=j&&i<j)
{
while(hash[i]<hash[high]&&i<j)// find higher numbers and lower numbers then the middlle and swaps them
{
i++;
}
while(hash[j]>hash[high]&&i<j)
{
j--;
}
if(i==j||i>j)
{
}
else
{
swap(hash[i],hash[j]);
swap(copyOfWords[i],copyOfWords[j]);
i++;
j--;
}
}
swap(hash[i],hash[high]);
swap(copyOfWords[i], copyOfWords[high]);
quickSort(low, j-1);//recursive
quickSort(j+1, high);
}
}
```

I know the values in hash and copyOfWords are accurate after reading this post since shell sort sorts them correctly. For example, if there are two words, copyOfWOrds[0]="1994," and copyOfWords[1]="a," then hash[0]=549456039 and hash[1]=197000000, but the sort places them as a 1994, a rather than a 1994,. With additional components, it produces greater complications. Any assistance would be much appreciated.

Thanks