title: How to make Quick Sort sort decimal numbers C#
body: <p>Here is a Quick Sort program that reads the numbers from the file and then sorts them smallest to highest. I need it to be able to do the exact same but for numbers with decimals. I understand there is ways of converting int to double, decimal or float, but I've tried everything i can and nothing is working, can someone show me how they would change this code in order to make it work. Below is how i've attempted to do it:</p>
  
  <pre><code>class quickSort
  {
  
  private double[] array = new double[1010];
  private int len;
  
  public void QuickSort()
  {
      sort(0, len - 1);
  }
  
  public void sort(double left, double right)
  {
      double pivot;
      double leftend, rightend;
  
      leftend = left;
      rightend = right;
      pivot = array[left];
  
      while (left &lt; right)
      {
          while ((array[right] &gt;= pivot) &amp;&amp; (left &lt; right))
          {
              right--;
          }
  
          if (left != right)
          {
              array[left] = array[right];
              left++;
          }
  
          while ((array[left] &lt;= pivot) &amp;&amp; (left &lt; right))
          {
              left++;
          }
  
          if (left != right)
          {
              array[right] = array[left];
              right--;
          }
      }
  
      array[left] = pivot;
      pivot = left;
      left = leftend;
      right = rightend;
  
      if (left &lt; pivot)
      {
          sort(left, pivot - 1);
      }
  
      if (right &gt; pivot)
      {
          sort(pivot + 1, right);
      }
  }
  
  public static void Main()
  {
      quickSort q_Sort = new quickSort();
  
      string[] years = System.IO.File.ReadAllLines(@"C:\WS1_Rain.txt");
      var yearArray = years.Select(item =&gt; Convert.ToDouble(item));
      double[] array = yearArray.ToArray();
  
      q_Sort.array = array;
      q_Sort.len = q_Sort.array.Length;
      q_Sort.QuickSort();
  
      for (int j = 0; j &lt; q_Sort.len; j++)
      {
          Console.WriteLine(q_Sort.array[j]);
      }
      Console.ReadKey();
  }
    }
  }
  </code></pre>