title: How to sort an associative array by its values in Javascript?
body: <p>I have the associative array:</p>
  <pre><code>array[&quot;sub2&quot;] = 1;
  array[&quot;sub0&quot;] = -1;
  array[&quot;sub1&quot;] = 0;
  array[&quot;sub3&quot;] = 1;
  array[&quot;sub4&quot;] = 0;
  </code></pre>
  <p>What is the most elegant way to sort (descending) by its values where the result would be an array with the respective indices in this order:</p>
  <pre><code>sub2, sub3, sub1, sub4, sub0
  </code></pre>