I'm not sure where in my code the problem occurs. I need a second pair of eyes (or maybe lots) to help me figure it out. The point of the function is to take a struct made up of a book title, and a book author (or authors but its all one line), and alphabetize it according to either author or title. Since they will work almost the same, I just want to focus on title first. Basically, I use a nested for loop, convert the ith and jth elements of the struct to integer and compare the letters one by one. The problem is that not all the all segments are being correctly alphabetized. Specifically, the one starting with "Java."
------------------------------The struct contains------------------------------
Objects First with Java (Barnes and Kolling)
Game Development Essentials (Novak)
The Game Maker's Apprentice (Overmars)
C++ Programming: From Problem Analysis... (Malik)
C++ Programming Lab Manual (Scholl)
Beginning LINUX Programming (Stones and Matthew)
C++ Programming: Program Design Including... (D. S. Malik)
C++ How to Program (Deitel and Deitel)
Programming and Problem Solving with C++ (Dale, Weems, Headington)
Game Character Development with Maya (Ward)
Developing Games in Java (Brackeen)
C# Programming (Harvey, Robinson, Templeman, Watson)
Java Programming (Farrell)
Audio for Games (Brando)
------------------------------Pertinent Code-----------------------------------
struct Book {
string title;
string author;
};
void sortByTitle (int count) //(count is 14)
{
int counter = 0;
for (int i = 0; i < count; i++)
{
string tempTitle, tempAuth;
int inti, intj;
---------------------------------After sorting---------------------------------
Audio for Games (Brando)
Beginning LINUX Programming (Stones and Matthew)
C# Programming (Harvey, Robinson, Templeman, Watson)
Java Programming (Farrell)
C++ Programming Lab Manual (Scholl)
C++ How to Program (Deitel and Deitel)
C++ Programming: From Problem Analysis... (Malik)
C++ Programming: Program Design Including... (D. S. Malik)
Developing Games in Java (Brackeen)
Game Character Development with Maya (Ward)
Game Development Essentials (Novak)
Objects First with Java (Barnes and Kolling)
Programming and Problem Solving with C++ (Dale, Weems, Headington)
The Game Maker's Apprentice (Overmars)