I'm currently attempting to organize an Object that contains only properties which are arrays. My goal is to sort these arrays based on their length in order to ensure that when using Object.keys(), the resulting list will display all names in the correct order. Below is the code I've come up with so far (though I acknowledge that it may not be entirely accurate at the moment due to mental exhaustion):
function sortSetsByAmount(SETS, callback) {
let sortedObject = {};
for (let i = Object.keys(SETS).length - 1; i >= 0; i--) {
let biggestSet = [];
for (let j = Object.keys(SETS).length; j >= 0; j--) {
if (SETS[Object.keys(SETS)[i]].length > biggestSet.length) {
biggestSet = SETS[Object.keys(SETS)[i]];
}
if (j === 0) {
sortedObject[Object.keys(SETS)[i]] = biggestSet;
}
}
}
callback(sortedObject);
}
}