diff --git a/src/lib/components/admin/Evaluations/Leaderboard.svelte b/src/lib/components/admin/Evaluations/Leaderboard.svelte index d8407a574..de99a6752 100644 --- a/src/lib/components/admin/Evaluations/Leaderboard.svelte +++ b/src/lib/components/admin/Evaluations/Leaderboard.svelte @@ -281,6 +281,28 @@ onMount(async () => { rankHandler(); }); + + $: sortedModels = [...rankedModels].sort((a, b) => { + let aVal, bVal; + if (orderBy === 'name') { + aVal = a.name; + bVal = b.name; + return direction === 'asc' ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal); + } else if (orderBy === 'rating') { + aVal = a.rating === '-' ? -Infinity : a.rating; + bVal = b.rating === '-' ? -Infinity : b.rating; + return direction === 'asc' ? aVal - bVal : bVal - aVal; + } else if (orderBy === 'won') { + aVal = a.stats.won === '-' ? -Infinity : Number(a.stats.won); + bVal = b.stats.won === '-' ? -Infinity : Number(b.stats.won); + return direction === 'asc' ? aVal - bVal : bVal - aVal; + } else if (orderBy === 'lost') { + aVal = a.stats.lost === '-' ? -Infinity : Number(a.stats.lost); + bVal = b.stats.lost === '-' ? -Infinity : Number(b.stats.lost); + return direction === 'asc' ? aVal - bVal : bVal - aVal; + } + return 0; + });
@@ -452,27 +474,7 @@ - {#each [...rankedModels].sort((a, b) => { - let aVal, bVal; - if (orderBy === 'name') { - aVal = a.name; - bVal = b.name; - return direction === 'asc' ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal); - } else if (orderBy === 'rating') { - aVal = a.rating === '-' ? -Infinity : a.rating; - bVal = b.rating === '-' ? -Infinity : b.rating; - return direction === 'asc' ? aVal - bVal : bVal - aVal; - } else if (orderBy === 'won') { - aVal = a.stats.won === '-' ? -Infinity : Number(a.stats.won); - bVal = b.stats.won === '-' ? -Infinity : Number(b.stats.won); - return direction === 'asc' ? aVal - bVal : bVal - aVal; - } else if (orderBy === 'lost') { - aVal = a.stats.lost === '-' ? -Infinity : Number(a.stats.lost); - bVal = b.stats.lost === '-' ? -Infinity : Number(b.stats.lost); - return direction === 'asc' ? aVal - bVal : bVal - aVal; - } - return 0; - }) as model, modelIdx (model.id)} + {#each sortedModels as model, modelIdx (model.id)}