Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays & selection_sort

Status
Not open for further replies.

lbucko

Programmer
Feb 13, 2002
11
0
0
IE
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
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top