title: Iterating over a JavaScript object in sort order based on particular key value of a child object
body: <p>Short version: I'm looking for the JavaScript equivalent of Perl's</p>
  
  <pre><code>for my $key ( sort { $hash{$a}{foo} cmp $hash{$b}{foo} } keys %hash ) {
      # do something with $key
  }
  </code></pre>
  
  <p>More detail:</p>
  
  <p>I have a JSON object which consists of a bunch of other JSON objects which have identical properties to each other, like a hash of hashes in Perl: eg:</p>
  
  <pre><code>var peopleobj = { 
      "0291" : { "Forename" : "Jeremy", "Surname" : "Dyson" },
      "0398" : { "Forename" : "Billy", "Surname" : "Bunter" },
      "6714" : { "Forename" : "Harry", "Surname" : "Peterson" },
      "9080" : { "Forename" : "Barry", "Surname" : "Mainwaring"}
  }
  </code></pre>
  
  <p>I want to iterate through the objects in <code>peopleobj</code> in order of the surname values, eg to print out the names in surname order. Plain JavaScript or jQuery solutions will work in the context in which this is being deployed.</p>
  
  <p>Thanks in advance for your valuable time.</p>