I am working on homework so please don't write it for me, but I am having 
trouble figuring our my error with a sort for a C program I am writing. it 
compiles fine, but it is not sorting the way I think it should. The source 
file is:
Ed Whittle 11.50 25.50 0.00
Paula Prentiss 15.75 50.50 125.00
Louise Marion 13.00 40.00 100.00
John Doe 17.00 46.50 50.00
Carl Davidson 8.75 38.00 15.00

and I am getting this output order.

    Davidson, Carl    8.75      38.00     332.50    47.62     24.61     241.93
                                 0.00                3.33     15.00
 
    Whittle, Ed      11.50      25.50     293.25    43.99     22.73     223.46
                                 0.00                3.08      0.00
 
    Prentiss, Paula  15.75      40.00     878.06   112.96     58.36     573.83
                                10.50                7.91    125.00
 
    Marion, Louise   13.00      40.00     520.00    63.00     32.55     320.04
                                 0.00                4.41    100.00
 
    Doe, John        17.00      40.00     845.75   119.36     61.67     606.36
                                 6.50                8.36     50.00


  for(a = 0; a < MAX-1; a++)
  {
    for(b = 0; b < MAX-1; b++)
    {
      if(strcmp(emp[b].LAST, emp[b+1].LAST))
        {
          Sort_List(&emp[b], &emp[b+1]);
        }
    }
  }


and the function 


void Sort_List(struct EmpData * R1, struct EmpData * R2)

{
  struct EmpData        tmp;

  tmp = *R1;
  *R1 = *R2;
  *R2 = tmp;
    
}

Reply via email to