1. ## Help, bubble-sort algorithm

Hi there im studying for exams going over previous exams and I have this question im not sure even where to start ill show you the question and if anyone can help me that would be great.

write a C functions strsort, using the bubble-sort algorithm, that has a single string as an argument.When the function finishes, the string is sorted in alphabetical order.

e.g.

after the following statements:
char s[80] = "horse";
strsort(s);

s contains "ehors"

2. Code:
```void bubbleSort (int list [],
int last)
{

int current;

for(current = 0; current < last; current++)
bubbleUp (list, current, last);

return;
}       /* bubbleSort */

void bubbleUp (int list[],
int current,
int last)
{

int walker;
int temp;

for (walker = last; walker > current; walker--)
if (list[walker]  < list[walker - 1])
{
temp             = list[walker];
list[walker]     = list[walker - 1];
list[walker - 1] = temp;
} /* if */
return;
}       /* bubbleUp */```

3. thanks jennifer!!!

4. that bubble up function is damn confusing.. how exactly dose that work... what is the reason for having it?

5. This is the output figure out how it work.

Results:
Unsorted array: 89 72 3 15 21 57 61 44 19 98 5 77 39 59 61
Sorted array: 3 5 15 19 21 39 44 57 59 61 61 72 77 89 98

6. whicked! thanks alot!!! gonna check it out now!

7. Remember jennifer, hints not answers right off the bat.