js sort array by time

array.sort(function(a,b){  
  return new Date(b.date) - new Date(a.date);
});