diff --git a/index.js b/index.js index ec77a49..37a83a5 100644 --- a/index.js +++ b/index.js @@ -88,7 +88,7 @@ candidateInfo.innerHTML = '

Candidates:

'; const candidatesList = document.createElement('ul'); - row.candidates.forEach(candidate => { + row.candidates.sort((a, b) => b.votes - a.votes).forEach(candidate => { const listItem = document.createElement('li'); listItem.innerHTML = ` ${candidate.name[0]} (${candidate.name[1]}) - ${candidate.votes} votes