Sorting a string using bubble sort?!
I want to sort an array of strings. To do this I must use the bubble sort method correct? I just pull out the first letter of each string convert it to it's ascii value then sort correct?
but how do I tell it to only pull out the first letter of the string? I would also need to sure the string header and copy the strings instead of using tmp. correct?
void sort(char a[], int n){
int i, j
for (i=0; i < n - 1; ++i)
for (j = n - 1; i < j; --j)
if (a[j-1] > &a[j])
swap(&a[j-1], &a[j]);
}
void swap(int *p, int *q)
{
int tmp;
tmp = *p;
*p = *q;
*q = tmp;
}