diff --git a/src/utils/index.ts b/src/utils/index.ts index 8c3650f2..24720d0b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,8 +2,8 @@ import moment from "moment"; export function dateSorter(a: any, b: any, direction: "asc" | "desc", key: string) { if (!a[key] && !b[key]) return 0; - if (a[key] && !b[key]) return direction === "asc" ? -1 : 1; - if (!a[key] && b[key]) return direction === "asc" ? 1 : -1; + if (a[key] && !b[key]) return direction === "asc" ? 1 : -1; + if (!a[key] && b[key]) return direction === "asc" ? -1 : 1; if (moment(a[key]).isAfter(b[key])) return direction === "asc" ? 1 : -1; if (moment(b[key]).isAfter(a[key])) return direction === "asc" ? -1 : 1; return 0;