From 2efc7655f4258d9c2dd507a32b3343c1bd829feb Mon Sep 17 00:00:00 2001 From: Gibson Han <66423127+gibsonliketheguitar@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:55:10 +0700 Subject: [PATCH] add function correct fcn express to sort in accending order --- src/hooks/useTable/useTableConfig.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hooks/useTable/useTableConfig.ts b/src/hooks/useTable/useTableConfig.ts index a2fa953d..76e40cdc 100644 --- a/src/hooks/useTable/useTableConfig.ts +++ b/src/hooks/useTable/useTableConfig.ts @@ -157,7 +157,6 @@ const useTableConfig = (tableId?: string) => { */ const remove = (key: string) => { const { columns } = tableConfigState; - /** * Filter column, and remove key index * Sort and reorder column @@ -165,7 +164,7 @@ const useTableConfig = (tableId?: string) => { */ const updatedColumns: any = Object.values(columns) .filter((c: any) => c.key !== key) - .sort((c: any) => c.index) + .sort((a: any, b: any) => a.index - b.index) .reduce((acc: any, curr: any, index: any) => { acc[curr.key] = { ...curr, index }; return acc;