Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock QSortAssoc(numbers[][], sort_index, left, right, pivot[], len)
- {
- new
- // pivot = numbers[left],
- l_hold = left ,
- r_hold = right ;
- memcpy(pivot, numbers[left], 0, len * 4, len);
- // A print tells me it crashes here; this is consistent
- while (left < right)
- {
- while ((numbers[right][sort_index] >= pivot[sort_index]) && (left < right)) right--;
- if (left != right)
- {
- memcpy(numbers[left], numbers[right], 0, len * 4, len);
- left++;
- }
- while ((numbers[left][sort_index] <= pivot[sort_index]) && (left < right)) left++;
- if (left != right)
- {
- memcpy(numbers[right], numbers[left], 0, len * 4, len);
- right--;
- }
- }
- memcpy(numbers[left], pivot, 0, len * 4, len);
- pivot[sort_index] = left;
- left = l_hold;
- right = r_hold;
- if (left < pivot[sort_index]) QSortAssoc(numbers, sort_index, left, pivot[sort_index] - 1, pivot, len);
- if (right > pivot[sort_index]) QSortAssoc(numbers, sort_index, pivot[sort_index] + 1, right, pivot, len);
- }
Advertisement
Add Comment
Please, Sign In to add comment