- /* compare value */
- //what group does this row belong to
- string z = index[(low + high) / 2];
-
- /* partition */
- do {
- /* find member above ... */
- while(index[i] < z) i++;
-
- /* find element below ... */
- while(index[j] > z) j--;
-
- if(i <= j) {
- /* swap two elements in row*/
- y = matrix[row][i];
- matrix[row][i] = matrix[row][j];
- matrix[row][j] = y;
-
- /* swap two elements in column*/
- y = matrix[i][row];
- matrix[i][row] = matrix[j][row];
- matrix[j][row] = y;
-
- //swap map elements
- z = index[i];
- index[i] = index[j];
- index[j] = z;
-
- i++;
- j--;
-//cout << "swapping elements " << i << " " << j << endl;
-//printMatrix(cout); cout << endl;
- }
- } while(i <= j);
-
- /* recurse */
- if(low < j)
- quicksort(low, j, row);
-
- if(i < high)
- quicksort(i, high, row);