Hello again guys,
I've created a bubblesort function to sort a string in chronological order, it is as follows:
void playerSort(int player, double ppg[])
{
int i,j;
char a[999][15];
char temp[15];
/* Converting LF into String */
for(i=0;i<player;i++)
{
sprintf(a[i],"%.2f",ppg[i]);
}
/* Sorting Array */
for(i=1;i<player;i++)
for(j=0;j<player-i;j++)
{
if(strcmp(a[j+1],a[j])<0)
{
strcpy(temp,a[j]);
strcpy(a[j],a[j+1]);
strcpy(a[j+1],temp);
}
}
}
when this sorting function is called in my main function, nothing happens at all. The strings are not sorted. It's like the program isnt even calling the function at all.
/* Calling of sort function */
playerSort(j,ppg);
/* Printing sorted list by PPG */
for(i=1;i<j;i++)
{
printf("%2d %5s, %5s \t %s\t%s\t%s %s %s %3s %3.2lf\n",index[i],lastname[i],firstname[i],team[i],pos[i],games[i],goals[i],assists[i],points[i],ppg[i]);
}
I'm not sure what's going wrong.
thanks for the help in advance.