Created
February 2, 2015 18:10
-
-
Save rafaeljesus/28c833235ea756355677 to your computer and use it in GitHub Desktop.
sort by date asc and desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sortKeysDesc(formattedDate1, formattedDate2) { | |
| var date1 = moment(formattedDate1); | |
| var date2 = moment(formattedDate2); | |
| if (date1.isSame(date2) ) return 0; | |
| return date1.isAfter(date2) ? -1 : 1; | |
| }; | |
| function sortKeysAsc(formattedDate1, formattedDate2) { | |
| var date1 = moment(formattedDate1); | |
| var date2 = moment(formattedDate2); | |
| if (date1.isSame(date2) ) return 0; | |
| return date1.isAfter(date2) ? 1 : -1; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment