title: Sorting of array with Moment(date) elements
body: <p>I have an array that is populated with moment(Date provided by the database) elements. I am trying to sort the array so that the first element is the oldest and  the last element is the newest, but with no success.</p>
  
  <pre><code>     for (let item of items) {
  
              dates.push(moment(item.created));
            }
            dates.sort(function(a,b){
              var da = new Date(a).getTime();
              var db = new Date(b).getTime();
  
              return da &lt; db ? -1 : da &gt; db ? 1 : 0
            });
      }
    console.log(dates);
  </code></pre>
  
  <p>This always prints the current time times number of elements.</p>