Or the slightly more concise:
d3.entries(statkeycolumns).sort(function(a, b){
return -a.value.localeCompare(b.value);
}))
To use d3.ascending, you'd need to wrap it up to pluck out the right key-value, maybe like this:
function keySort(sortfunc, field){
return function(a, b){
return sortfunc(a[field], b[field]);
}
}
d3.entries(statkeycolumns).sort(keySort(d3.ascending, "value"));
If you only ever bind them to one selection, you can do this inline:
d3.selectAll("div")
.data(columns)
.call(function(init){
init.enter().append("div");
})
.sort(function(a, b){
return -a.value.localeCompare(b.value);
})
.text(function(d){ return d.value; });
But if you are going to use the list somewhere else where order is relevant, you'll want to sort the entries array itself.
I hope one of these helps!