Hi I need to know how to sort an array of stucts based on one of the fields. I have to go from smallest to largest. The struct has 4 fields in it: int processNbr; int totalTime; int remainingTime; int stopTime; int isFinished;. I think i'm really only concerned with processNbr and totalTime I have it to where it finds and prints the smallest ok but from there i dont know how to "scratch that one off the list" and find the next one and print it and then find the next largest and print it. I have a for loop go through the array to find the smallest but then how do i run through it again to find the next smallest. I'll post the function that i'm talking about. It is for a cpu time schedule simulator for shortest job first job processing method thats why i need to sort by the totalTime field and put the smallest first, followed by the next smallest and so on and then somehow keep track of the order so i can print the processNbr and totalTime for each of them in the order they would finish at the end.
//###################################################################
void scheduleSJF(processDataType processes[], int processCount)
{
int i;
int minimumProcessTimeIndex;
int minimumProcessRunningTime = processes[0].totalTime;
for (i = 1; i < processCount; i++)
{
if (processes[i].totalTime < minimumProcessRunningTime)
{
minimumProcessRunningTime = processes[i].totalTime;
minimumProcessTimeIndex = i;
} // end if
} // end for
printf("the lowestRunning time is %d\n", minimumProcessRunningTime);
printf("the minimumProcessTimeIndex is %d\n", minimumProcessTimeIndex);
} // end sechudleSJF