From da93b79c78d9bfe448a8b0fe79e8e99ab27ee9c4 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sun, 21 Jan 2024 13:34:48 +0000 Subject: [PATCH] Solved an issue with sorting --- src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;