Skip to content

Commit b9c05c6

Browse files
committed
Sort parties based on political spectrum
1 parent e18d8e0 commit b9c05c6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ <h1>Valgsimulator</h1>
5858
<option>Navn</option>
5959
<option>Stemmer</option>
6060
<option>Mandater</option>
61+
<option>Farge (subjektivt)</option>
6162
</select>
6263
</span>
6364
<span>

valg.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ function update() {
339339
} else if (sortParties == "Mandater") {
340340
var globalSeats = sumLocal(seats);
341341
parties.sort((party1, party2) => compare(party1, party2, globalSeats));
342+
} else if (sortParties == "Farge (subjektivt)") {
343+
var spectrum = ["NKP", "RØDT", "SV", "A", "SP", "MDG", "KYST", "KRF", "V", "H", "FRP", "KRISTNE", "LIBS", "DEMN", "AAN"];
344+
var rightism = {};
345+
for (var party of parties) {
346+
rightism[party] = spectrum.includes(party) ? spectrum.indexOf(party) : 10000;
347+
}
348+
parties.sort((party1, party2) => compare(party2, party1, rightism));
342349
}
343350

344351
printTable(voteTable, votes, parties, mergeParties, mergeDistricts, "Distriktsstemmer", showFraction, true, true, decimals);

0 commit comments

Comments
 (0)