Skip to content

Commit 7ab8a55

Browse files
author
Allordiron
committed
Improve sort alghorithm
1 parent 54d37ff commit 7ab8a55

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

js/bundle.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ let app = new Vue({
1313
this.dates.sort((date1, date2) => {
1414
date1 = new Date(date1);
1515
date2 = new Date(date2);
16-
17-
return date1.getDate() + date1.getMonth() < date2.getDate() + date2.getMonth();
16+
17+
if (date1.getMonth() == date2.getMonth()) {
18+
return date1.getDate() < date2.getDate();
19+
}
20+
else if (date1.getMonth() > date2.getMonth()) {
21+
return false;
22+
}
23+
else {
24+
return true;
25+
}
1826
});
1927
},
2028
createTask: function(title, date) {

0 commit comments

Comments
 (0)