Hi everyone!
If anybody could tell me why this sort is not working I would greatly appreciate it.
I'm trying to sort by last name, first name and middle initial. I have the last name sorted, but it seems to stop there. I've looked at this and tried so many different things for so long I think I may just be missing something silly.
Code:
void Sort(vector<Names>& Access, vector<Entry>& Process, int& i)
// Pre condition: Add function has been accessed
// Post condition: Returns sorted Phone book
{
int j;
struct Name temp[20];
struct Phone_Book_Entry temp2[20];
cout << Process.size();
for(i=0; i<=Process.size(); i++)
{
for(j=i+1; j<=Process.size(); j++)
{
if (Access[i].lastName > Access[j].lastName)
{
temp[i] = Access[i];
Access[i] = Access[j];
Access[j] = temp[i];
temp2[i] = Process[i];
Process[i] = Process[j];
Process[j] = temp2[i];
if (Access[i].firstName > Access[j].firstName)
{
temp[i] = Access[i];
Access[i] = Access[j];
Access[j] = temp[i];
temp2[i] = Process[i];
Process[i] = Process[j];
Process[j] = temp2[i];
if (Access[i].middleIni > Access[j].middleIni)
{
temp[i] = Access[i];
Access[i] = Access[j];
Access[j] = temp[i];
temp2[i] = Process[i];
Process[i] = Process[j];
Process[j] = temp2[i];
} // End 3rd if
} // End 2nd if
} // End 1st if
} // End for j
} // End for i
} // End Sort function