title: Sort object of weekdays like Sunday, Monday, ..., Saturday
body: <p>How to sort Javascript object of week days by weekdays i.e Here, is JSON format of object:</p>
  
  <pre><code> {"Friday":["5:00pm to 12:00am"] ,"Wednesday":["5:00pm to 11:00pm"],"Sunday":["11:00am to 11:00pm"], "Thursday":["5:00pm to 11:00pm"],"Saturday":["11:00am to 12:00am"]}
  </code></pre>
  
  <p>where key is day i.e."Wednesday". I want to sort it based on order of weekdays i.e Sunday, Monday, Tuesday etc</p>
  
  <p>Expected Output is:</p>
  
  <pre><code>{ "Wednesday":["5:00pm to 11:00pm"], "Thursday":["5:00pm to 11:00pm"], "Friday":["5:00pm to 12:00am"], "Saturday":["11:00am to 12:00am"], "Sunday":["11:00am to 11:00pm"]}
  </code></pre>
  
  <p>this is what i was trying.</p>
  
  <pre><code>var keys = {}; 
  Object.keys(scope.daySpecificHours)
  .map(function (k) { return [k, scope.daySpecificHours[k]]; })
  .sort(function (a, b) {
  if (a[0] &lt; b[0]) return -1;
  if (a[0] &gt; b[0]) return 1;
  return 0;
  })
  .forEach(function (d) {
  scope.daySpecificHours[d[0]] = d;
  });
  </code></pre>
  
  <p>Thanks.</p>