How to sort a dynamic array of heterogeneous numbers?
<p>I want to sort an array that can contain different numeric types (double, float, etc.).This code raises a System.ArgumentException ("Value is not a System.Single") error:</p>

<pre><code>new dynamic[] { 5L, 4D, 3F, 2U, 1M, 0UL }.ToList().Sort();
</code></pre>

<p>I know I can use LINQ to do this:</p>

<pre><code>new dynamic[] { 5L, 4D, 3F, 2U, 1M, 0UL }.ToList().OrderBy(x =&gt; (decimal)x).ToArray();
</code></pre>

<p>But is there a faster way that doesn't involve going through any having to cast each element?</p>

<p>Addendum: I would also like to be able to handle nulls in the list, so even the LINQ query's cast won't help.</p>
