Is there a select_sort function for sorting arrays, I was told about but don't know how to use it. I want to sort an array according to a score assigned to each element
smrt_res is a struct of type Res. I want to sort this array based on score.
Code:
void smart_2(FILE *file, char *query, Res results[][100])
{
FILE *ffp;
char phrase[100];
Res smrt_res[100];//array to write results to
int i =0;
int count=0;//number of occurrences
char fname[20];
int f=0; //file passed in
while(query[i] != '\0')
{
tolower(query[i]);
i++;
}
while(fgets(fname, 100, file) != NULL)
{
f++;
ffp=fopen(fname, " ");
while(fgets(phrase, 100, ffp))
{
if(strstr(phrase, query) != NULL)
{
count++;
}
fclose(ffp);
smrt_res[f].doc_id=f;
smrt_res[f].score=count;
count=0;
}
}
}//smart_2
smrt_res is a struct of type Res. I want to sort this array based on score.