sorting structure members using pointers

Hello, I am working through the book C Primer Plus by Stephen Prata, and am stuck on problem 3 in Chapter 14. I have no classmates or teachers, and cannot for the life of me see why this thing won't sort.

The structure, along with the function that will sort the members that are the 'title' strings, is here:e in the sorting part, though I am using a simple "bubble sort" that should work.

With a bubblesort, you have to do the sort over and over again until no swaps took place.

That's not your whole function, right?

dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

When sorting an index table without modifying the data table, you need to make sure that the changes to the index table are reflected in the comparisons for the sort. Here is an algorithm that does this, and also uses a mandatory optimization for bubble sort:

With a bubblesort, you have to do the sort over and over again until no swaps took place.

That's not your whole function, right?

Actually, I did neglect to include the terminal bracket "}", but that is all I did not include.

As I have read documentation about the "bubble sort" (knowing that it is the "worst" kind of sorting algorithm, but I just want to get the dang thing to work right now), I saw from various sources that if you looped through the outer loop once for each element in the set, that would be sufficient, even in the worst case scenario, unless I misuderstood.

Thank you, dwks.

@ Prelude:
Thank you, too,
and I will have to take my time to look carefully at what you have posted there.

>knowing that it is the "worst" kind of sorting algorithm
Well, it's easy to come up with something worse than bubble sort, but you're not likely to see anything worse in real code.

>but I just want to get the dang thing to work right
In my opinion, selection sort is much easier to get right the first time than bubble sort, and it has more useful performance properties than bubble sort.