From be065e2de304ee34716c3a17c4bde08585434efd Mon Sep 17 00:00:00 2001 From: Whitewater Date: Thu, 25 May 2023 00:33:02 -0700 Subject: [PATCH] fix: sort in desc based update date by default (#2510) --- packages/component/src/components/page-list/all-page.tsx | 2 +- packages/component/src/components/page-list/use-sorter.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/component/src/components/page-list/all-page.tsx b/packages/component/src/components/page-list/all-page.tsx index e9974ff6e9..dbc1812411 100644 --- a/packages/component/src/components/page-list/all-page.tsx +++ b/packages/component/src/components/page-list/all-page.tsx @@ -117,7 +117,7 @@ export const PageList = ({ }: PageListProps) => { const sorter = useSorter({ data: list, - key: 'createDate', + key: 'updatedDate', order: 'desc', }); diff --git a/packages/component/src/components/page-list/use-sorter.ts b/packages/component/src/components/page-list/use-sorter.ts index 77b18f3c89..ab08e0397d 100644 --- a/packages/component/src/components/page-list/use-sorter.ts +++ b/packages/component/src/components/page-list/use-sorter.ts @@ -9,7 +9,7 @@ type SorterConfig = { const defaultSortingFn = >( ctx: { key: keyof T; - order: 'asc' | 'desc' | 'none'; + order: 'asc' | 'desc'; }, a: T, b: T @@ -21,10 +21,10 @@ const defaultSortingFn = >( return 0; } if (typeof valA === 'string') { - return valA.localeCompare(valB as string) * (revert ? 1 : -1); + return valA.localeCompare(valB as string) * (revert ? -1 : 1); } if (typeof valA === 'number') { - return valA - (valB as number) * (revert ? 1 : -1); + return valA - (valB as number) * (revert ? -1 : 1); } return 0; };