void QuickSort( employee employees[], int index[], int start, int finish ) { int outer; int inner; int left = start; int right = finish; int pivot = (start + finish) / 2; do { while ( strcmp(employees[index[left]].last_name, employees[index[pivot]].last_name) < 0 ) { left++; } // if left is not less than pivot, then left stays the same because we want to exchange it while ( strcmp(employees[index[right]].last_name, employees[index[pivot]].last_name) > 0 ) { right--; } // if right is not more than pivot, then right stays the same because we want to exchange it printf("%d %d", left, right); if ( left < right ) { printf("%d %d 2", left, right); Swap(&index[left], &index[right]); left++; right--; } } while ( left < right ); printf("!"); printf("%d %d", start, finish); if ( start < right ) { QuickSort(employees, index, start, right); } if ( left < finish ) { QuickSort(employees, index, left, finish); } system("PAUSE"); for ( outer = start; outer < finish; outer++) { printf("%d %d %s", start, finish, employees[index[outer]].last_name); } }