title: Array to Sort High Scores
body: <p>I'm working on a project in C# that involves keeping track of the top five high scores for a rock paper scissors game. Right now I have an array to hold the top five scores (which are integers), I sort the array in descending order, and I use a for loop to compare the score just earned by the user to the scores currently in the array. If the new score is higher than one in the array, right now the new score just takes the space in the array that the lower one occupied. </p>
  
  <p>For example, if the scores were 9, 8, 5, 3, 1 and the user scored a 6, the scores would then look like this: 9, 8, 6, 3, 1. I wondered if there's a way for me to shift the lower scores over and insert the new one, so the list would look like this: 9, 8, 6, 5, 3.</p>
  
  <p>This is the code I currently have, where successPercent is the score, calculated as wins divided by losses and ties:</p>
  
  <pre><code>int[] scoreArray = { 84, 25, 36, 40, 50 };
  
  Array.Sort(scoreArray);
  Array.Reverse(scoreArray);
  
  for (int x = 0; x &lt;= scoreArray.Length; ++x)
  {
      if (successPercent &gt; scoreArray[x])
      {
          scoreArray[x] = Convert.ToInt32(successPercent);
          break;
      }
  }
  </code></pre>