From 28c85cc271ea62b418e345e1446d695f55757493 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Wed, 21 May 2025 21:28:54 +0300 Subject: [PATCH] fix sort --- src/utils/time.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/utils/time.ts b/src/utils/time.ts index c89c1cd..a3bb0bf 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -43,14 +43,15 @@ export function formatTimestamp(timestamp: number): string { // Both have timestamp, sort by timestamp descending return b.timestamp - a.timestamp; } else if (a.timestamp) { - // Only `a` has timestamp, it comes first return -1; } else if (b.timestamp) { - // Only `b` has timestamp, it comes first return 1; } else { - // Neither has timestamp, sort alphabetically by groupName - return a.groupName.localeCompare(b.groupName); + // Neither has timestamp, sort alphabetically by groupName (with fallback) + const nameA = a.groupName || ''; + const nameB = b.groupName || ''; + return nameA.localeCompare(nameB); } }); - } \ No newline at end of file + } + \ No newline at end of file