Quicksort random numbers in listbox + IMG
<p>I am trying to Quicksort 10 random numbers within an listbox. But i cant use the method on my random iar, can anyone give me some advice.</p>

<p>Code behind button:</p>

<pre><code>         private void btnSort_Click(object sender, EventArgs e)
    {
        Random r = new Random();
        int n = 10;
        int[] iar = new int[n];
        for (int i = 0; i &lt; iar.Length; i++)
        {
            iar[i] = r.Next(0, 20);
            lb1.Items.Add(iar[i]);

        //here is the error i want to fill lb2 with the quicksorted array 
        // using the quicksort method

            Quicksort(iar, 0, iar.Length - 1);
        }
        for (int i = 0; i &lt; iar.Length; i++)
        {
            lb2.Items.Add(iar[i]);
        }
    }
</code></pre>

<p>Quicksort method</p>

<pre><code> public static void Quicksort(IComparable[] elements, int left, int right)
    {
        int i = left, j = right;
        IComparable pivot = elements[(left + right) / 2];

        while (i &lt;= j)
        {
            while (elements[i].CompareTo(pivot) &lt; 0)
            {
                i++;
            }
            while (elements[j].CompareTo(pivot) &gt; 0)
            {
                j--;
            } 
            if (i &lt;= j)
            {
                // Swap
                IComparable tmp = elements[i];
                elements[i] = elements[j];
                elements[j] = tmp;

                i++;
                j--;
            }
        }
        // Recursive calls
        if (left &lt; j)
        {
            Quicksort(elements, left, j);
        }
        if (i &lt; right)
        {
            Quicksort(elements, i, right);
        }
    }

}
</code></pre>

<p>ERRORS:</p>

<p>Error   2   Argument 1: cannot convert from 'int[]' to 'System.IComparable[]'<br>
Error   1   The best overloaded method match for 'Quicksort.FrmQuicksort.Quicksort(System.IComparable[], int, int)' has some invalid arguments</p>

<p>Thanxs for looking:)</p>
