Hello,

I am having trouble with an assignment at college. Now, I don't want anyone to write the program for me. I just want to understand the concepts.

Problem Specification:
I have to get a list of names and data to go with those names from an infile, sort them and then print them to the screen. The program works until I get to the actual sorting. It is returning weird values and not sorting anything. If someone could tell me what's wrong with the sort function and explain the concepts I don't have right?

The code in question:
Code:
/*datalength is the number of entries from the datafile*/
void SortData (int datalength, char full [50][40], char last [50][20], char first [50][20], double fall [], double winter [], double spring [], double summer [], double total [])
{
	int i;
	int j;
	char chartemp [40];
	double doubletemp;
	
	char comma [2] = {","};
	
	/*Combines the last and first names into one array: full, and inserts a comma between them / Works*/
	for (i = 0; i < datalength; i++)
	{
		strcpy (full [i], last [i]);
		strcat (full [i], comma);
		strcat (full [i], first [i]);
	}
	
	/*The part that doesn't work, the lower variable value is giving weird or wrong answers*/
	for (i = 0; i < datalength; i++)
	{
		lowest = i;
		for (j = i + 1; j < datalength; j++)
		{
			if (strcmp (full [j], full [lowest]) < 0);
				lowest = j;
			if (i != lowest)
			{
				strcpy (chartemp, full [j]);
				strcpy (full [j], full [i]);
				strcpy (full [i], chartemp);
			
				doubletemp = fall [j];
				fall [j] = fall [i];
				fall [i] = doubletemp;
				
				doubletemp = winter [j];
				winter [j] = winter [i];
				winter [i] = doubletemp;
			
				doubletemp = spring [j];
				spring [j] = spring [i];
				spring [i] = doubletemp;
				
				doubletemp = summer [j];
				summer [j] = summer [i];
				summer [i] = doubletemp;
				
				doubletemp = total [j];
				total [j] = total [i];
				total [i] = doubletemp;
			}
		}
	}
}
A small part of the datafile looks like this:
Code:
Hill Justin 2785.00 2282.00 5720.00 6330.00
Ortego Taylor 4715.00 1676.00 6067.00 929.00
Stoilova Nadica 1253.00 1495.00 2884.00 4173.00
I don't understand the sorting concept in relation to the code.
Please help!