title: Mimic PHP's ksort in C#
body: <p>I never thought I would have to ask this... I need a way to mimic PHP's <code>ksort</code> function in C#.</p>
  
  <p>Here's the problem... PHP does this...</p>
  
  <p><strong>PHP CODE</strong></p>
  
  <pre><code>$arr = array(
      "tagValues" =&gt; "asdfasd",
      "email" =&gt; "asdfasd",
      "referrer" =&gt; "asdfasd",
      "tags" =&gt; "asdfasd",
  );
  
  echo "Base array \n\n";
  print_r($arr);
  
  ksort($arr);
  
  echo "\n\nksort'ed array \n\n";
  print_r($arr);
  </code></pre>
  
  <p><strong>PHP OUTPUT</strong></p>
  
  <pre><code>Base array 
  
  Array
  (
      [tagValues] =&gt; asdfasd
      [email] =&gt; asdfasd
      [referrer] =&gt; asdfasd
      [tags] =&gt; asdfasd
  )
  
  
  ksort'ed array 
  
  Array
  (
      [email] =&gt; asdfasd
      [referrer] =&gt; asdfasd
      [tagValues] =&gt; asdfasd
      [tags] =&gt; asdfasd
  )
  </code></pre>
  
  <p>While if I do this in C#...</p>
  
  <pre><code>string[] sortedKeys = form.AllKeys.OrderBy(x =&gt; x).ToArray();
  </code></pre>
  
  <p>It comes out in a different order. <code>tags</code> will be before <code>tagValues</code>, as it rightfully should be. That is the true alphabetically order.</p>
  
  <p>It's my understanding that <code>ksort</code> does some kind of case-sensitive ASCII work on the array and that's why it comes out in a different order.</p>
  
  <p><em><strong>How can I implement that in C#?</em></strong> Preferably with LINQ. Thanks!</p>
  
  <p><em>For those interest in the backstory...</em></p>
  
  <p>I'm basically trying to create an MD5 hash of input parameters sorted in alpha order per the <a href="http://www.fastspring.com/" rel="nofollow">FastSpring</a> API. Their PHP snippet operates differently than I expected when I translated to C#, so the hash is always incorrect.</p>