title: Sort array by date gives unexpected results
body: <p>This will sound as an easy problem but I spent my Sunday trying to figure out what's wrong with my implementation described below so I am posting it to SO as a last resort. </p>
  
  <p>I have a javascript application that receives data structures from a server. The server side sends the data unsorted for performance reasons.</p>
  
  <p>Here is a snippet of the the javascript code receiving data:</p>
  
  <pre><code>    var seriesRawDataArray = ko.observableArray();
      ...
      analyticscontext.series(seriesRawDataArray).done(function () {
          renderSeries();
      });
  </code></pre>
  
  <p>The <code>analyticscontext</code> module queries the data using ajax:</p>
  
  <pre><code>function series(seriesData) {
      return $.ajax({
          url: "/api/analytics/series",
          type: "GET",
          success: function (data) {
              return seriesData(data);
          }
      });
  }
  </code></pre>
  
  <p>The <code>renderSeries</code> performs a sort on the data before rendering it:</p>
  
  <pre><code>    // Sort the data by date using moment.js
      seriesRawDataArray.sort(function (left, right) {
          var leftDate = moment.utc(left.timeStamp);
          var rightDate = moment.utc(right.timeStamp);
          var diff = leftDate.diff(rightDate);
          return diff &gt; 0;
      });
  </code></pre>
  
  <p><strong>PROBLEM</strong></p>
  
  <p>Here is a data sample I receive from my server:
  <img src="https://i.stack.imgur.com/pIQW1.png" alt="enter image description here"></p>
  
  <p>Notice the unsorted items at the end.
  the <code>seriesRawDataArray.sort</code> seem to have no effect on the original array which does not get sorted no matter what I change in the sorting method. The output is always:</p>
  
  <p><img src="https://i.stack.imgur.com/TngZx.png" alt="enter image description here"></p>
  
  <p>Notice the unsorted elements here. 
  The libraries I am using and the data is definitely not the problem as this <a href="http://jsfiddle.net/u3gzpp7h/" rel="noreferrer">jsfiddle</a> works just fine!
  Is there something wrong with this code?</p>