From 509d8dc6e90d40f30a10d53e6d0957165d06850a Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 15 Dec 2022 10:40:54 +0100 Subject: [PATCH] sorting correction in MyEntries --- src/components/specific_challenge/MyEntries/MyEntries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/specific_challenge/MyEntries/MyEntries.js b/src/components/specific_challenge/MyEntries/MyEntries.js index 7107303..77deeca 100644 --- a/src/components/specific_challenge/MyEntries/MyEntries.js +++ b/src/components/specific_challenge/MyEntries/MyEntries.js @@ -91,11 +91,11 @@ const MyEntries = (props) => { // eslint-disable-next-line no-case-declarations let newScoresSorted = scoresSorted; if (scoresSorted[metricIndex]) { - newEntries = newEntries.sort((a, b) => b.evaluations[elem] - a.evaluations[elem]); + newEntries = newEntries.sort((a, b) => (b.evaluations ? b.evaluations[elem] : -1) - (a.evaluations ? a.evaluations[elem] : -1)); newScoresSorted[metricIndex] = false; setScoresSorted(newScoresSorted); } else { - newEntries = newEntries.sort((a, b) => a.evaluations[elem] - b.evaluations[elem]); + newEntries = newEntries.sort((a, b) => (a.evaluations ? a.evaluations[elem] : -1) - (b.evaluations ? b.evaluations[elem] : -1)); newScoresSorted[metricIndex] = true; setScoresSorted(newScoresSorted); }