title: Problem trying to use the C qsort function
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  float values[] = { 4, 1, 10, 9, 2, 5, -1, -9, -2,10000,-0.05,-3,-1.1 };
  
  int compare (const void * a, const void * b)
  {
      return ( (int) (*(float*)a - *(float*)b) );
  }
  
  int main ()
  {
  
      int i;
  
      qsort (values, 13, sizeof(float), compare);
  
      for (i = 0; i &lt; 13; i++)
      {
          printf ("%f ",values[ i ]);
      }
      putchar('\n');
  
      return 0;
  }
  </code></pre>
  
  <p>The result is:</p>
  
  <p>-9.000000 -3.000000 -2.000000 -1.000000 -1.100000 -0.050000 1.000000 2.000000 4.000000 5.000000 9.000000 10.000000 10000.000000</p>
  
  <p>It's wrong because the order of -1 and -1.1 is changed.
  I believe it is happening because my "compare" function.</p>
  
  <p>How can I fix this?</p>
  
  <p>Thanks</p>