sorting correction in MyEntries

This commit is contained in:
Mateusz 2022-12-15 10:40:54 +01:00
parent c5d45ac7c4
commit 509d8dc6e9

View File

@ -91,11 +91,11 @@ const MyEntries = (props) => {
// eslint-disable-next-line no-case-declarations // eslint-disable-next-line no-case-declarations
let newScoresSorted = scoresSorted; let newScoresSorted = scoresSorted;
if (scoresSorted[metricIndex]) { 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; newScoresSorted[metricIndex] = false;
setScoresSorted(newScoresSorted); setScoresSorted(newScoresSorted);
} else { } 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; newScoresSorted[metricIndex] = true;
setScoresSorted(newScoresSorted); setScoresSorted(newScoresSorted);
} }