I've scoured numerous other resources with no luck in finding a satisfactory answer to this query.
It's common knowledge that JavaScript objects arrange their integer keys in ascending order, not in the order they were inserted.
const lookup = {}
lookup['1'] = 1
lookup['3'] = 3
lookup['2'] = 2
console.log(Object.keys(lookup)) -> ['1', '2', '3']
That part is straightforward. However, what is the big O notation for the internal sorting process? There must be some sort algorithm working behind the scenes to organize the keys as they are added, but I'm unable to determine which one.
When it comes to Array.sort(), Insertion Sort is used for arrays with a length of 10 or less, while Quick Sort is employed for arrays exceeding a length of 10.
Yet, Array.sort() rearranges an object's keys based on the sorting of its values.
So, how exactly does JavaScript sort its keys upon insertion?