Question sorting character arrays: C programming

I was just wondering why my code isn't working as it should, I will sort well for the FIRST letter, but will not keep checking to sort names in TRUE ALPHABETICAL order. Here is my function that I made to do this sorting:

for(pass = 0; pass < CLASS-1; pass++)

{

for(i = 0; i < CLASS-1; i++)

{

letterOne = students[i].lastName[0];

letterTwo = students[i+1].lastName[0];

if(letterOne > letterTwo)

{

for(k = 0; k < LAST_NAME; k++)

{

lastNameTempSpace[k] = students[i].lastName[k];

firstNameTempSpace[k] = students[i].firstName[k];

}

for(k = 0; k < LAST_NAME; k++)

{

students[i].lastName[k] = students[i+1].lastName[k];

students[i].firstName[k] = students[i+1].firstName[k];

}

for(k = 0; k < LAST_NAME; k++)

{

students[i+1].lastName[k] = lastNameTempSpace[k];

students[i+1].firstName[k] = firstNameTempSpace[k];

}

}

while(letterOne == letterTwo)

{

while(letterOne != ' ' && letterTwo != ' ')

{

l++;

letterOne = students[i].lastName[l+1];

letterTwo = students[i+1].lastName[l+1];

if(letterOne > letterTwo)

{

for(k = 0; k < LAST_NAME; k++)

{

lastNameTempSpace[k] = students[i].lastName[k];

firstNameTempSpace[k] = students[i].firstName[k];

}

for(k = 0; k < LAST_NAME; k++)

{

students[i].lastName[k] = students[i+1].lastName[k];

students[i].firstName[k] = students[i+1].firstName[k];

}

for(k = 0; k < LAST_NAME; k++)

{

students[i+1].lastName[k] = lastNameTempSpace[k];

students[i+1].firstName[k] = firstNameTempSpace[k];

}

if(letterOne == letterTwo)

{

letterOne = students[i].lastName[l];

letterTwo = students[i+1].lastName[l];

}

}

}

}

}

}