From 8d79a430a27e8378418daccdb0cc58ae13611b30 Mon Sep 17 00:00:00 2001 From: CJY Date: Mon, 6 May 2024 01:23:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=8C=8C=ED=8A=B8=EC=88=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20&&=20=EC=9D=B4=EB=A6=84=20=EA=B0=80=EB=82=98?= =?UTF-8?q?=EB=8B=A4=EC=88=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mypage/TotalScoreSection.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/mypage/TotalScoreSection.tsx b/src/components/mypage/TotalScoreSection.tsx index 6b12c67..7a8790f 100644 --- a/src/components/mypage/TotalScoreSection.tsx +++ b/src/components/mypage/TotalScoreSection.tsx @@ -19,6 +19,7 @@ const TotalScoreSection = ({ myName }: { myName: string }) => { const [clickedUser, setClickedUser] = useState({} as UserScore); const scoreChanged = useRecoilValue(userScoreChanged); const [isPre, setIsPre] = useState(false); + const [sortScoreArray, setSortScoreArray] = useState([]); useEffect(() => { if (myName === '최재영' || myName === '박재윤') { @@ -59,8 +60,18 @@ const TotalScoreSection = ({ myName }: { myName: string }) => { } }); setTotalScoreArray(Object.values(tmpObject)); + const sort = totalScoreArray.sort((a: UserScore, b: UserScore) => { + if (a.track !== b.track) { + return a.track - b.track; + } + return a.name.localeCompare(b.name, 'ko'); + }); + setSortScoreArray(sort); } }, [totalAssignment, totalAttendance]); + + if (totalScoreArray) { + } return ( <> @@ -77,7 +88,7 @@ const TotalScoreSection = ({ myName }: { myName: string }) => { ))} - {totalScoreArray.map((userScore, i) => ( + {sortScoreArray.map((userScore, i) => ( {userScore.name}