title: How to sort an associative array by value and keep values?
body: <p>I have an associative array named map:</p>
  
  <pre><code>     var map = new Array();
       map["exampleKey"] = 7;
  </code></pre>
  
  <p>The keys are strings and the values are integers. Some keys may have the same value.</p>
  
  <p>I have tried solutions from similar questions like <a href="https://stackoverflow.com/questions/5199901/how-to-sort-an-associative-array-by-its-values-in-javascript">this one.</a>
  However, I have not found one yet that preserves the values. They simply creates arrays with the keys in order. I need a sort that stores the keys and values in order (sorted by value) into some appropriate data structure.</p>
  
  <p>I also do not have a server so any solution must be JavaScript.</p>