title: How to sort and rank a vector in C++ (without using C++11)
body: <p>I am trying to construct a function take takes a vector, ranks it, sorts it and outputs the sorted and ranked vector with the original positioning of the values. For example:  Input: [10,332,42,0.9,0] Output: [3, 5, 4, 2, 1]</p>
  
  <p>I used this stack overflow <a href="https://stackoverflow.com/questions/13473/how-does-one-rank-an-array-sort-by-value-with-a-twist">question</a> (specifically Marius' answer) as a reference guide, however I am stuck with my code now and do not understand where the issue is.
  I am running a C++03.</p>
  
  <p>One of the errors I get is </p>
  
  <p><code>error: invalid types ‘const float*[float]’ for array subscript’ for array subscript</code> on my <code>if</code> statement.</p>
  
  <pre><code>//Rank the values in a vector
  std::vector&lt;float&gt; rankSort(const float *v_temp, size_t size)
  {
      vector &lt;float&gt; v_sort;
      //create a new array with increasing values from 0 to n-1
      for(unsigned i = 0; i &lt; size; i++)
      {
          v_sort.push_back(i);
      }
      bool swapped = false;
      do
      {
          for(unsigned i = 0; i &lt; size; i++)
          {
              if(v_temp[v_sort[i]] &gt; v_temp[v_sort[i+1]]) //error line
              {
                  float temp = v_sort[i];
                  v_sort[i] = v_sort[i+1];
                  v_sort[i+1] = temp;
                  swapped = true;
              }
          }
      }
      while(swapped);
      return v_sort;
  }
  
  std::vector&lt;float&gt; rankSort(const std::vector&lt;float&gt; &amp;v_temp)
  {
      return rankSort(&amp;v_temp[0], v_temp.size());
  }
  </code></pre>