Realizing that sorting objects is not feasible - despite the necessity of having the object values sorted - I conclude that the only option is to move the object array content into a new array for sorting purposes.
The following code generates the output shown below without utilizing any array function:
https://i.sstatic.net/cnGLQ.png
This represents my code snippet:
var aveArr = {};
var length = 0;
var q = d3.queue();
['insert csv here', 'insert another csv here'].map((c) => {
q.defer(d3.csv, c);
length += 1;
});
q.awaitAll(function(d, csvs){
var selection = d3.merge(csvs);
selection.map((d,i) => {
aveArr[d.word] = {
sum: 0,
average: 0,
};
var obj = aveArr[d.word];
obj.sum += +d.frequency;
obj.average = obj.sum / length;
});
console.log(aveArr);
});
I solely require the word and average values to appear in the console, followed by sorting the averages.
I came across this resource on pushing data to arrays, but unfortunately, it didn't work for me.