title: Why is my Parallel QuickSort method slower than the sequential method?
body: <p>I am new to parallel programming and I am unsure why the <code>QuickSortParallel</code> method is slower than my sequential version (Without the Parallel.Invoke). I have a jagged array that consists of a hundred thousand 9 digit numbers that I pass to be sorted. Unfortunately, when I use the <code>QuickSortParallel</code> method it ends up being almost 5 times slower than the sequential version. </p>
  
  <p>Could I do more than just using Parallel.Invoke on the data source?  </p>
  
  <pre><code>    public static void QuickSort_Parallel&lt;T&gt;(T[] array2) where T : IComparable&lt;T&gt;
      {
          QuickSortParallel(array2, 0, array2.Length - 1);
      }
  
      private static void QuickSortParallel&lt;T&gt;(T[] array2, int left, int right)
          where T : IComparable&lt;T&gt;
      {
          if (left &gt;= right)
          {
              return;
          }
  
          SwapElements(array2, left, (left + right) / 2); //median pivot
          int last = left;
          for (int current = left + 1; current &lt;= right; ++current)
          {
              //CompareTo, compares current array index value with
              if (array2[current].CompareTo(array2[left]) &lt; 0)
              {
                  ++last;
                  SwapElements(array2, last, current);
              }
          }
  
          SwapElements(array2, left, last);
          //Recursive
          //Executes each of the provided actions in parallel.
          Parallel.Invoke(
              () =&gt; QuickSortParallel(array2, left, last - 1),
              () =&gt; QuickSortParallel(array2, last + 1, right)
          );
      }
  
      static void SwapElements&lt;T&gt;(T[] array2, int i, int j)
      {
          T temp = array2[i];
          array2[i] = array2[j];
          array2[j] = temp;
      }
  </code></pre>