ellimist14 -1 Light Poster

First off let me say please don't tell me another sort to use. I am being forced to use the QuickSort. Anyway I have some code written out and it compiles and runs and messes with the order of the list but does not sort it. I'll post the code below and if you can figure out what's going on please help me out

void node::quickSortID ( node *start_ptr, int low, int high)
{
 int pivotPoint;
 if (low < high)
 {
  // Get the pivot point.
  pivotPoint = partition (start_ptr, low, high);
  //Sort sublist A.
  quickSortID (start_ptr, low, pivotPoint-1);
  //Sort sublist B.
  quickSortID (start_ptr, pivotPoint +1, high);
 }
}

int node::partition (node *start_ptr, int low, int high)
{
 node *ptr = start_ptr, *ptr2=start_ptr, *ptr3= start_ptr;
 int pivotValue,pivotIndex, mid, i;

 mid = (low+high)/2;
 for (i=0; i<mid; i++)
 {
  ptr = ptr->nxt;
 }
 swap (start_ptr->emp, ptr->emp);
 pivotIndex = low;
 pivotValue = start_ptr -> emp.ID;
 for (int scan = low+1; scan <= high; scan++)
 {
  if (ptr2->emp.ID < pivotValue)
  {
   pivotIndex++;
   ptr3 = ptr3->nxt;
   swap (ptr3->emp, ptr2->emp);
  }
 }
 swap (start_ptr->emp, ptr3->emp);
 return pivotIndex;
}

The head pointer is properly initialized and low is initialized to 0 and high is initialized to the number of items in my linked list. emp is a struct defined thusly

struct EMP
{
        int ID;
        string lname;
        string fname;
        int yrs;
        int prod;

};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.