title: Sorting a 2D Char and Int Array from class using bubble sort?
body: <p>I am trying to sort an array of <code>int</code> and <code>char</code>s (from a class) by descending order. These are student names and grades.</p>
  
  <p>The class is defined as:</p>
  
  <pre><code>class Student {
  public:
      char name[20];
      int grades;
  };
  </code></pre>
  
  <p><code>numCount</code> is the incremental value of number of records.</p>
  
  <pre><code>void bubble_sort(Student theResults[], int numCount)
  {
    bool swapped = true;
    while(swapped)
    {
      swapped = false;
      for(int i=1;i&lt;numCount;i++)
      {
        if(theResults[i-1].grades &lt; theResults[i].grades)
        {
          int tempHold = theResults[i-1].grades;
          theResults[i-1].grades = theResults[i].grades;
          theResults[i].grades = tempHold;
          swapped = true;
        }
      }
    }
  </code></pre>
  
  <p>The issue I am having is that the <code>int</code> values (grades) are sorted correctly after the loop but having difficulty getting the names to be correctly allocated to match with the grades.</p>
  
  <p>I have used the following code but it doesn't work as it displays the incorrect grades for the students.</p>
  
  <pre><code>char* title_temp = theResults[i-1].name;
  theResults[i-1].name[20] = theResults[i].name[20];
  theResults[i].name[20] = title_temp[20];
  </code></pre>