Skip to main content
Spacing
Source Link
joshuakcockrell
  • 6.3k
  • 2
  • 43
  • 54

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b) { return a.getTime() - b.getTime() });

Using the arrow function way

array.sort((a,b)=>a => a.getTime() - b.getTime());

found here: Sort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

Using the arrow function way

array.sort((a,b)=>a.getTime()-b.getTime());

found here: Sort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b) { return a.getTime() - b.getTime() });

Using the arrow function way

array.sort((a,b) => a.getTime() - b.getTime());

found here: Sort date in Javascript

Added an alternative using the arrow function
Source Link
Teocci
  • 9.4k
  • 1
  • 71
  • 56

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});
array.sort(function(a,b){return a.getTime() - b.getTime()});

Using the arrow function way

array.sort((a,b)=>a.getTime()-b.getTime());

found here: Sort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

found here: Sort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

Using the arrow function way

array.sort((a,b)=>a.getTime()-b.getTime());

found here: Sort date in Javascript

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

found here: Sort date in JavascriptSort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

found here: Sort date in Javascript

@Phrogz answers are both great, but here is a great, more concise answer:

array.sort(function(a,b){return a.getTime() - b.getTime()});

found here: Sort date in Javascript

Source Link
Gal
  • 5.9k
  • 1
  • 24
  • 21
Loading