title: c++ sort: ranking list with same value of an array
body: <p>I'm trying to show a ranking list of my array qt, which contains 5 numbers.</p>
  
  <pre><code>int i, j;
  int qt[5] = {10,20,10,50,20};
  int tempqt;
  for (i=0; i&lt;5; i++)
  {
      for(j=(i+1); j&lt;5; j++)
      {
          if (qt[i] &gt;= qt[j])
          {
              tempqt = qt[i];
              qt[i] = qt[j];
              qt[j] = tempqt;
          }
      }
  }
  
  for(i=0; i&lt;5; i++)
  {
      cout &lt;&lt; i+1 &lt;&lt; ".number: " &lt;&lt; qt[i] &lt;&lt; endl;
  }
  </code></pre>
  
  <p>normally, the 2 for-loops sort my array and the last for-loop displays my array ordered, so it looks like this:</p>
  
  <ul>
  <li>1.number: 10</li>
  <li>2.number: 10</li>
  <li>3.number: 20</li>
  <li>4.number: 20</li>
  <li>5.number: 50</li>
  </ul>
  
  <p>But I want to display the numbers with the same value as the same ranking position, so like this:</p>
  
  <ul>
  <li>1.number: 10</li>
  <li>1.number: 10</li>
  <li>2.number: 20</li>
  <li>2.number: 20</li>
  <li>3.number: 50</li>
  </ul>