How do I bubble sort alphabetically?
OK, I have a bubble sort function, which i've adapted to sort a list of names alphabetically. But the function won't sort past the first character in each word, so I get a list of names beginning with a, names beginning with b etc... The function won't distinguish between say 'alex' or 'adam'. Is there a simple way I can fix this? My Bubble sort code is:
Code:
int u,v;
for(v=1; v<i; v++)
for(int j=v-1; j>=1; j--)
{
if(strcmp(value[j-1].f_name , value[j].f_name)>0)
{
u = *value[j-1].f_name;
*value[j-1].f_name = *value[j].f_name;
*value[j].f_name = u;
}
}