问题
I have two jsons.
First: here
Second: here
How to sort second json by first? I want to sort keys and it's values in second json by values in first json.
回答1:
You could do something like this
var first = ["name0", "name1", "name2"]
var second = { {"name2":"xyz", "name0" : "xyz", "name1" : "xyz" } }
for( var i = 1; i < Object.keys(second).length; i++ ){
var aux = {}
first.forEach(function(element2) {
resul[element2] = second[i][element2]
});
}
来源:https://stackoverflow.com/questions/54029071/how-to-sort-keys-in-json-by-another-json-values