Solved an issue with sorting
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user