Top Score Sorter

const maxScore = 1218000;
const scoreSet = [874300, 879200, 1172100, 1141800, 933900, 1177200, 1190200, 1110100, 1158400, 985600, 1047200, 1049100, 1138600, 1170500, 1064500, 1190000, 1050200, 1090400, 1062800, 1061700, 1218000, 1068000, 1127700, 1144800, 1195100];

function scoreSettler(scores, max) {
  "use strict";
  const sparseArr = [];
  
  for (let i = 0, l = scores.length; i < l; i++) {
    const diff = (max - scores[i]) / 100;
    sparseArr[diff] = scores[i];
  }
  
  return filter(sparseArr);
}

// To ensure I was building my own processes I replaced a call to the
// Array.prototype.filter method with my own filter to remove empty
// indexes.

function filter(arr) {
  "use strict";
  const newArr = [];
  
  for (let i = 0, l = arr.length; i < l; i++) {
    if (arr[i]) {
      newArr.push(arr[i]);
    }
  }
  return newArr;
}

console.log(scoreSettler(scoreSet, maxScore));