I have three vectors
vector<string> a_words0(75000);
vector<string> a_words1(75000);
vector<string> a_words2(75000);
Consider below how the elements look like of the same row:
.
.
.
It's raining outside
The warrior is
It's raining heavily
It's raining outside
.
.
.
I was using the quicksort function to sort according to the first vector, and it's giving me the following results
.
.
.
It's raining outside
It's raining heavily
It's raining outside
The warrior is
.
.
.
The thing is I want the duplicates to be together like this:
.
.
.
It's raining outside
It's raining outside
It's raining heavily
The warrior is
.
.
.
This is my quick sort function:
void quicksort(vector<string> &arr0, vector<string> &arr1,vector<string> &arr2,int low, int high)
{
int i = low;
int j = high;
string y = "Z";
/* compare value */
string z = arr0[(low + high) / 2];
/* partition */
do {
/* find member above ... */
while(arr0[i] < z) i++;
/* find element below ... */
while(arr0[j] > z) j--;
if(i <= j) {
/* swap two elements */
y = arr0[i];
arr0[i] = arr0[j];
arr0[j] = y;
y = arr1[i];
arr1[i] = arr1[j];
arr1[j] = y;
y = arr2[i];
arr2[i] = arr2[j];
arr2[j] = y;
i++;
j--;
}
} while(i <= j);
/* recurse */
if(low < j)
quicksort(arr0,arr1,arr2, low, j);
if(i < high)
quicksort(arr0,arr1,arr2, i, high);
}