我正在尝试根据 cummulativeSite 通过 object.keys 降序对javascript中的对象 obj 进行排序,但它没有被排序。请提出一个好的方法或方法来对它进行排序。
var obj={
B.E:{
A: {percentgsite: 8.5, backlogenclsite: 8.5, regularenclsite: 3.5, cummulativeSite: 20.5},
B: {percentgsite: 5.9, backlogenclsite: 5.9, regularenclsite: 8.5, cummulativeSite: 20.3},
C: {percentgsite: 5.9, backlogenclsite: 6.4, regularenclsite: 8.9, cummulativeSite: 21.200000000000003}
},
Diploma:{
A: {percentgsite: 8.5, cummulativeSite: 5.2},
B: {percentgsite: 5.9, cummulativeSite: 8.5},
C: {percentgsite: 5.9, cummulativeSite: 5.6}
},
M.E:{
A: {percentgsite: 8.5, cummulativeSite: 11.9},
B: {percentgsite: 5.9, cummulativeSite: 12.9},
C: {percentgsite: 5.9, cummulativeSite: 13.5}
}
}
预期输出:
var obj={
B.E:{
C: {percentgsite: 5.9, backlogenclsite: 6.4, regularenclsite: 8.9, cummulativeSite: 21.200000000000003},
A: {percentgsite: 8.5, backlogenclsite: 8.5, regularenclsite: 3.5, cummulativeSite: 20.5},
B: {percentgsite: 5.9, backlogenclsite: 5.9, regularenclsite: 8.5, cummulativeSite: 20.3}
},
Diploma:{
B: {percentgsite: 8.5, cummulativeSite: 8.5},
C: {percentgsite: 5.9, cummulativeSite: 5.6},
A: {percentgsite: 5.9, cummulativeSite: 5.2}
},
M.E:{
C: {percentgsite: 8.5, cummulativeSite: 13.5},
B: {percentgsite: 5.9, cummulativeSite: 12.9},
A: {percentgsite: 5.9, cummulativeSite: 11.9}
}
}