fix: sorting events by date

This commit is contained in:
Ondřej Synáček 2020-12-25 10:17:19 +01:00
parent 37d931f6ce
commit 579bde6c32
2 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ const createEventStore = () => {
startTime: startTime.toString(), startTime: startTime.toString(),
title, title,
}, },
] ].sort(sortRecord)
} }
state = nextState state = nextState

View File

@ -15,10 +15,10 @@ export const sortRecord = (a, b) => {
const bDate = new Date(b.createdAt) const bDate = new Date(b.createdAt)
if (aDate < bDate) { if (aDate < bDate) {
return -1 return 1
} }
if (aDate > bDate) { if (aDate > bDate) {
return 1 return -1
} }
return 0 return 0
} }