Loop Through A JavaScript Object Sorted By Key
Note, need to check about key/value usage here to make sure this is being save
Note that Object.entries passes an array with `[key, value]`
There's probably multiple ways to do it, but this is how I'm looping through an objects sorted by their keys
01const example_1 = {02 c: "x",03 a: "x",04 b: "x"05}0607const sorted_keys_1 = []0809Object.entries(example_1)010.sort((a, b) => a[0].localeCompare(b[0]))011.forEach((item) => sorted_keys_1.push(item[0]))
..
console.log(sorted_keys_1)
->
TODO: Write up details of how this works
01const example_2 = {02 c: "x",03 a: "x",04 b: "x"05}0607const sorted_keys_2 = Object.entries(example_2)08.sort((a, b) => a[0].localeCompare(b[0]))09.map((item) => item[0])
..
console.log(sorted_keys_2)
->