I have this dictionary:
{
"13.666666666666666": {
"data": 0
},
"1": {
"data": 0
},
"0.5": {
"data": 0
}
}
I wish to sort the dictionary so that the keys are in numerical order as such:
{
"0.5": {
"data": 0
},
"1": {
"data": 0
},
"13.666666666666666": {
"data": 0
}
}
How do I sort a dictionary by numerical value of key in javascript? This is for debugging purposes - not for iteration.
I know I can do this for iteration purposes:
const keys = Object.keys(my_dict).sort(function(a, b){return a-b});
for (const key of keys) {
const value = my_dict[key]
}