I am having difficulty with a code in which I have to use selection sorting to sort a list of indexes. The program compiles, but the function I am using to perform the swap doesn't seem to be doing anything. The program is supposed to look at the alphabetical order from the Last Name = lName, to make the list descending order. Any help would be appreciated.
Code:
void sort(PERSON people[], int num)
{
int pass, trav, min;
for (pass = 0; pass < num; pass++);
{
for (min = pass, trav = pass +1; trav < num; trav++)
{
if (strcmp(people[trav].fName, people[min].fName) == 0)
{
min = trav;
}
}
swap(people[trav], people[min]);
}
}
void swap (PERSON people1, PERSON people2)
{
PERSON temp = {"", "", 0, "", {0,0,0}};
printf("bebebe");
strcpy(temp.fName, people1.fName);
strcpy(temp.lName, people1.lName);
temp.Glevel = people1.Glevel;
strcpy(temp.ssn, people1.ssn);
temp.bDate.month = people1.bDate.month;
temp.bDate.day = people1.bDate.day;
temp.bDate.year = people1.bDate.year;
strcpy(people1.fName, people2.fName);
strcpy(people1.lName, people2.lName);
people1.Glevel = people2.Glevel;
strcpy(people1.ssn, people2.ssn);
people1.bDate.month = people2.bDate.month;
people1.bDate.day = people2.bDate.day;
people1.bDate.year = people2.bDate.year;
strcpy(people2.fName, temp.fName);
strcpy(people2.lName, temp.lName);
people2.Glevel = temp.Glevel;
strcpy(people2.ssn, temp.ssn);
people2.bDate.month = temp.bDate.month;
people2.bDate.day = temp.bDate.day;
people2.bDate.year = temp.bDate.year;
}