l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2001 Dec 30 17:10

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] C sorting problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] C sorting problem



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;
    
}


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.