title: How do I sort a hash table in Javascript?
body: <p>I have a Javascript hash table, like so:</p>
  
  <pre><code>var things = [ ];
  things["hello"] = {"name" : "zzz I fell asleep", "number" : 7};
  things["one"] = {"name" : "something", "number" : 18};
  things["two"] = {"name" : "another thing", "number" : -2};
  </code></pre>
  
  <p>I want to sort these into order by name, so if I iterate through the hash table it will go in order</p>
  
  <pre><code>another thing
  something
  zzz I fell asleep
  </code></pre>
  
  <p>I tried doing this:</p>
  
  <pre><code>function compareThings(thing1, thing2) {
      var name1 = thing1["name"].toLowerCase();
      var name2 = thing2["name"].toLowerCase();
      if (name1 &lt; name2) {
          return -1;
          }
      if (name1 &gt; name2) {
          return 1;
          }
      return 0;
  }
  
  things.sort(compareThings);
  </code></pre>
  
  <p>But it doesn't seem to work.</p>
  
  <p>Edit: it occurs to me that perhaps a sorted hash table is an oxymoron. If so, what's the best way to get access to a sorted list of the things here?</p>