From f654936e45a16638de01385e283df4fd546bb98a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o?= <43091603+glazk0@users.noreply.github.com>
Date: Sat, 22 Apr 2023 14:32:35 +0200
Subject: [PATCH] Change sort base on scoreMax
---
ui/Puzzles.tsx | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/ui/Puzzles.tsx b/ui/Puzzles.tsx
index 8f26d5d..6a54d7a 100644
--- a/ui/Puzzles.tsx
+++ b/ui/Puzzles.tsx
@@ -151,26 +151,7 @@ export default function Puzzles({ token }: { token: string }) {
{filteredData &&
filteredData
- .sort((p1, p2) => {
- const p1Tags = p1.tags || [];
- const p2Tags = p2.tags || [];
- const p1Easy = p1Tags.some((tag) => tag.name === 'easy');
- const p2Easy = p2Tags.some((tag) => tag.name === 'easy');
- if (p1Easy !== p2Easy) {
- return p1Easy ? -1 : 1;
- }
- const p1Medium = p1Tags.some((tag) => tag.name === 'medium');
- const p2Medium = p2Tags.some((tag) => tag.name === 'medium');
- if (p1Medium !== p2Medium) {
- return p1Medium ? -1 : 1;
- }
- const p1Hard = p1Tags.some((tag) => tag.name === 'hard');
- const p2Hard = p2Tags.some((tag) => tag.name === 'hard');
- if (p1Hard !== p2Hard) {
- return p1Hard ? -1 : 1;
- }
- return p1Tags.length - p2Tags.length;
- })
+ .sort((a, b) => a.scoreMax - b.scoreMax)
.map((puzzle) => (
))}