Sorting by Name (alphabetic) - Dual arrays
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7788358/sorting-by-name-alphabetic">Sorting by Name (alphabetic)</a>  </p>
</blockquote>



<p>Say I have the code below.  I have a total of 6 radio buttons.  I have the 5 of the radio buttons working.  The last is called radio button is called rbRegion.  I believe I have everything set up correctly.  There are two arrays, one for strings, and one for 4 quarterly totals and one yearly total.  Say I wanted to sort by region name, I would place it in the `if (rbRegion.Checked) area.  What exactly would I need to place in there to sort it alphabetically and to change the corresponding numeric array. </p>

<pre><code>private void btnSort_Click(object sender, EventArgs e)
{
    int n;
    decimal temp;
    int sortCol = 0;
    string ntemp;
    bool swapFlag;

    if (rb1.Checked)
        sortCol = 0;        
    if (rb2.Checked)
        sortCol = 1;
    if (rb3.Checked)
        sortCol = 2;        
    if (rb4.Checked)
        sortCol = 3;        
    if (rbTotal.Checked)
        sortCol = 4;
    if (rbRegion.Checked)
    {
    }
    else
    {
        do
        {
            swapFlag = false;
            for (n = 0; n &lt; lastIndexUsed; n++)
            {
                if(quarters[n,sortCol] &lt; quarters[n+1, sortCol])
                {
                    //column 4
                    temp = quarters[n, 4];
                    quarters[n, 4] = quarters[n + 1, 4];
                    quarters[n+1, 4] = temp; 

                    //col 3
                    temp = quarters[n, 3];
                    quarters[n, 3] = quarters[n + 1, 3];
                    quarters[n + 1, 3] = temp; 

                    //col 2
                    temp = quarters[n, 2];
                    quarters[n, 2] = quarters[n + 1, 2];
                    quarters[n + 1, 2] = temp;

                    // col 1
                    temp = quarters[n, 1];
                    quarters[n, 1] = quarters[n + 1, 1];
                    quarters[n + 1, 1] = temp;

                    //col 0
                    temp = quarters[n, 0];
                    quarters[n, 0] = quarters[n + 1, 0];
                    quarters[n + 1, 0] = temp;

                    //name
                    ntemp = Branch[n];
                    Branch[n] = Branch[n + 1];
                    Branch[n + 1] = ntemp;
                    swapFlag = true;        
                }//endif
            }//for end
        } while (swapFlag);
    }
</code></pre>
