Swapping two array elements on c++ structer – sorting by alphabet order

  alphabet, arrays, c++

I have a problem with this part here, I want to sort the students in alphabet order, can you help me? I tried to swap between elements but the issue is student 2 and 4 info s[2] and s[4] show as random text.
The code with issue:

  struct student
    char name[31];
    int grade1;
    int grade2;
    int grade3;
    double average;

student s[5];

and after input goes this:

student temp[5];

for (int i = 1; i <= 3; i++) 
    for (int j = 2; j <= 4; j++) 
        if (s[i].name[0] > s[j].name[0]) 
            temp[i] = s[i];
            swap(s[i], s[j]);
            s[j] = temp[i];

Source: Windows Questions C++