Do your strings really contain all capital letters?
And do you required to:
1) Use loops and manual comparison instead of builtin lexographical comparison? Lines 38-40 can be replaced with if(PlayerNames[count] > PlayerNames[count+1])
2) Write your own sorting function. Whole code can be replaced with calling std::sort with predicate.
Yes, it contains all Capital letters. I am will write the correct algorithm for numbering when I solve this.
1. I don't understand this.
2. I have several vectors that need to be sorted together that is why I am writing my own instead of using sort. (PlayerNames, PlayerScores, PlayerRanks, etc.)
2. Usually parallel data structures are sign of a bad design. Why not combine all these into one structure containing all data together and have one vector of structures.
Either way, you better move all comparison stuff into a single function returning a bool.
Your code should look like:
1 2 3 4 5 6 7 8 9 10 11
do
{
swap = false;
for (int count = 0; count < (PlayerNames.size() - 1); ++count++) {
if (not compare(PlayerNames[count], PlayerNames[count + 1]) {
// Swap everything
swap = true;
}
//Nothing here
}
} while (swap);
In that case lines AC and AB would be threated as if they were in correct order.
As long as you do not mess with letter variable, your loop would reach the end eventually. It would not swap stuff repeadetly because there is a break after swap exactly for that.