After finding out that sorting objects is not possible - even though I need the values of the objects sorted - I believe that I have to push the content of the object array to an array for sorting.
My code below produces this output without implementing any send to an array function:
This is my code:
var aveArr = {};
var length = 0;
var q = d3.queue();
['csv goes here', 'another csv goes 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 only need the word and average to be displayed in the console, then for the averages to be sorted.
I've found this for pushing content to arrays, but for me, it doesn't work.
