From f836d4fc24bfd8ea539e5eecfe2a2b77cba54438 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Mon, 16 Oct 2023 20:07:05 +0200 Subject: [PATCH] Fix icpc csv export --- .../kotlin/org/icpclive/export/icpc/csv/IcpcCsvExporter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cds-converter/src/main/kotlin/org/icpclive/export/icpc/csv/IcpcCsvExporter.kt b/src/cds-converter/src/main/kotlin/org/icpclive/export/icpc/csv/IcpcCsvExporter.kt index 990e1d5bb..be4a40ed8 100644 --- a/src/cds-converter/src/main/kotlin/org/icpclive/export/icpc/csv/IcpcCsvExporter.kt +++ b/src/cds-converter/src/main/kotlin/org/icpclive/export/icpc/csv/IcpcCsvExporter.kt @@ -37,12 +37,12 @@ object IcpcCsvExporter { val rows = info.teams.keys.associateWith { scoreboardCalculator.getScoreboardRow(info, runsByTeam[it] ?: emptyList()) } val ranking = scoreboardCalculator.getRanking(info, rows) val ranks = ranking.order.zip(ranking.ranks).toMap() - val icpcTeamIds = info.teams.values.map { it.icpcId() to it.id }.sortedByDescending { ranks[it.second] } + val icpcTeamIds = info.teams.values.associate { it.id to it.icpcId() } return buildString { val printer = CSVPrinter(this, CSVFormat.DEFAULT.builder().setHeader(*fields.toTypedArray()).build()) - for ((icpc_id, team_id) in icpcTeamIds) { - printer.printRecord(getFields(icpc_id, ranks[team_id]!!, rows[team_id]!!, ranking.awards.filter { team_id in it.teams })) + for (teamId in ranking.order.reversed()) { + printer.printRecord(getFields(icpcTeamIds[teamId]!!, ranks[teamId]!!, rows[teamId]!!, ranking.awards.filter { teamId in it.teams })) } } }