diff --git a/frontend/src/robot/TotalStatistics.tsx b/frontend/src/robot/TotalStatistics.tsx index 029226c6a8e..cc19c00c454 100644 --- a/frontend/src/robot/TotalStatistics.tsx +++ b/frontend/src/robot/TotalStatistics.tsx @@ -141,33 +141,43 @@ const TotalStatisticsInternal: React.FunctionComponent = (): JSX.Element => { return Error loading statistics; } - const statistics = - totalStatisticsState.map((dataPoint) => { - const achievement = statisticsAchievements[dataPoint.type].find(achievement => { - return dataPoint.value >= achievement.value; - }); - - return ( - - - - - { - {achievement?.description || "No achievement yet"} - } - - - {getFriendlyStatName(dataPoint)} - - - {getHumanReadableStatValue(dataPoint)} - - - - - ); + const statistics = totalStatisticsState.sort((a, b) => { + const aMapped = SORT_ORDER[a.type] ?? 10; + const bMapped = SORT_ORDER[b.type] ?? 10; + + if (aMapped < bMapped) { + return -1; + } else if (bMapped < aMapped) { + return 1; + } else { + return 0; + } + }).map((dataPoint) => { + const achievement = statisticsAchievements[dataPoint.type].find(achievement => { + return dataPoint.value >= achievement.value; }); + return ( + + + + + { + {achievement?.description || "No achievement yet"} + } + + + {getFriendlyStatName(dataPoint)} + + + {getHumanReadableStatValue(dataPoint)} + + + + + ); + }); + return ( <> @@ -190,4 +200,10 @@ const TotalStatistics = (): JSX.Element => { ); }; +const SORT_ORDER = { + "time": 1, + "area": 2, + "count": 3 +}; + export default TotalStatistics;