From 8c25037cb8bc3b296c281c717e0824c1834e0b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:43:02 -0600 Subject: [PATCH] fix: default order --- .../tankopedia/components/TankSearch/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/tools/tankopedia/components/TankSearch/index.tsx b/src/app/tools/tankopedia/components/TankSearch/index.tsx index 7d06faf4e..511e54012 100644 --- a/src/app/tools/tankopedia/components/TankSearch/index.tsx +++ b/src/app/tools/tankopedia/components/TankSearch/index.tsx @@ -63,14 +63,20 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) { awaitedTanks .sort( (a, b) => - treeTypeOrder.indexOf(a.treeType) - - treeTypeOrder.indexOf(b.treeType), + (treeTypeOrder.indexOf(a.treeType) - + treeTypeOrder.indexOf(b.treeType)) * + (sort.direction === 'descending' ? -1 : 1), ) .sort( (a, b) => - tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type), + (tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type)) * + (sort.direction === 'descending' ? -1 : 1), ) - .sort((a, b) => nations.indexOf(a.nation) - nations.indexOf(b.nation)), + .sort( + (a, b) => + (nations.indexOf(a.nation) - nations.indexOf(b.nation)) * + (sort.direction === 'descending' ? -1 : 1), + ), [], ); const input = useRef(null);