Skip to content

Instantly share code, notes, and snippets.

@anuk79
Created June 9, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuk79/4c180dc44b09776ef26d3dac4c1db2d4 to your computer and use it in GitHub Desktop.
Save anuk79/4c180dc44b09776ef26d3dac4c1db2d4 to your computer and use it in GitHub Desktop.
  import moment from 'moment';
  const datesArr = ['2020-03-01', '2020-01-10', '2020-02-07'];
  const result  = datesArr.sort((d1, d2) => moment(d1) - moment(d2));

  console.log(result); // asc sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment