Skip to content
Advertisement

How treemap handles case of putting key on same index?

I tried out following code:

JavaScript

But output is coming as :

JavaScript

Why we are not getting all the five keys in output?

EDIT :

Thank you all, I understood why I’m not getting all 5 keys in output, but I just wondering what would be best way to get all keys in sorted order of dots.

One idea, came to my mind is extract all keys, store them in list and sort that list based on no of dots, then use the same list to reorder the map? Any better ways

Advertisement

Answer

Because numbers of dots in the keys are :

JavaScript

Unique counts are : 2, 3 and 4

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement