diff --git a/src/hooks/use-replies.ts b/src/hooks/use-replies.ts index a7012212..3bc62d3e 100644 --- a/src/hooks/use-replies.ts +++ b/src/hooks/use-replies.ts @@ -17,12 +17,14 @@ const useRepliesAndAccountReplies = (comment: Comment) => { }, [flattenedReplies, accountComments]); const repliesAndNotYetPublishedReplies = useMemo(() => { - return [ + const repliesSortedByVotes = [ // put the author's unpublished replies at the top, latest first (reverse) ...accountRepliesNotYetPublished.reverse(), // put the published replies after, ...(flattenedReplies || []), ]; + // sort by timestamp + return repliesSortedByVotes.sort((a: Comment, b: Comment) => a.timestamp - b.timestamp); }, [flattenedReplies, accountRepliesNotYetPublished]); return repliesAndNotYetPublishedReplies;