I want to sort the records in a file in ascending order. Is there any predefined function for this? If there's none, can anyone give me a tutorial link, sample code, or an algorithm that would be helpful in solving my problem?
Thanks in advance.
EDIT:
I'm lost. Most people recommended mergesort. BUT how am I suppose to implement it in a code like this?
(display function)
Code:
void disp_all()
{
record stud;
rewind(fp);
clrscr();
printf("STUDENT#\t%-16s%-16s%-12s%-12s%-12s\n\n","LAST NAME","FIRST NAME","MI","BDAY", "COURSE ");
while(fread(&stud,sizeof(stud),1,fp))
{
if(stud.snum > 0)
{
printf("%lld\t", stud.snum);
printf("%-16s", stud.lname);
printf("%-16s", stud.fname);
printf("%-12s", stud.mi);
printf("%-12s", stud.bday);
printf("%-12s\n", stud.course);
}
}
getch();
}
Please...I need urgent help...