This is the code I have so far, took me along time to learn from googling. so basically, I open the file, read it, pass to a array, then sort it.
It's long, so thanks for reading it.
/*Promot user to enter file name*/
/* Open the file */
FILE *infile = fopen(infile_name, "r");
/* If the operation was unsuccessful */
printf("unable to open %s\n", infile_name);
/* Read the file */
fscanf(infile, "%d", &in); /* read from infile into int variable in */
if (!feof(infile)) /* only process in if didn't reach end of file */
instr=in; /* pass In to a array*/
/* Sorting */
int compare (const void *s, const void *t)
return (*(const int*)s - *(const int*)t);
int count =sizeof(instr)/sizeof(char);
qsort(instr, count, sizeof(int), (*compare)(const void *, const void *));