How to sort an (associative) array by value?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5199901/how-to-sort-an-associative-array-by-its-values-in-javascript">How to sort an associative array by its values in Javascript?</a>  </p>
</blockquote>



<p>So first off I know technically Javascript doesn't have associative arrays, but I wasn't sure how to title it and get the right idea across.</p>

<p>So here is the code I have,</p>

<pre><code>var status = new Array();
status['BOB'] = 10
status['TOM'] = 3
status['ROB'] = 22
status['JON'] = 7
</code></pre>

<p>And I want to sort it by value such that when I loop through it later on <code>ROB</code> comes first, then <code>BOB</code>, etc.</p>

<p>I've tried,</p>

<pre><code>status.sort()
status.sort(function(a, b){return a[1] - b[1];});
</code></pre>

<p>But none of them seem to actually DO anything.</p>

<p>Printing the array out to the console before and after result in it coming out in the same order.</p>
