From 3133ba4f22da9dc8030a16d8a66a3b3a229afa94 Mon Sep 17 00:00:00 2001 From: HoshinoSuzumi Date: Thu, 9 May 2024 11:04:50 +0800 Subject: [PATCH] fix(crac-question): sort questions by lk id --- app/api/crac/question-bank/[level]/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/crac/question-bank/[level]/route.ts b/app/api/crac/question-bank/[level]/route.ts index 21cae0f..c4e3f96 100644 --- a/app/api/crac/question-bank/[level]/route.ts +++ b/app/api/crac/question-bank/[level]/route.ts @@ -2232,7 +2232,7 @@ export async function GET( const serverSideProps = await getServerSideProps() const searchParams = req.nextUrl.searchParams - const questions: ExamQuestion[] = serverSideProps.props.banks[ctx.params.level] + const questions: ExamQuestion[] = serverSideProps.props.banks[ctx.params.level].sort((a, b) => a.id.localeCompare(b.id)) if (searchParams.get('shuffle') === 'true') { questions.sort(() => Math.random() - 0.5) }