The requirement was to paint only the values in descending order as they are the popular searches within the website. Whether we use for in loop or jquery each construct which does the same thing if the variable is an object, our results were varying across browsers namely Google chrome. The reason being in chrome, the key values were seen as array index instead of object key properties. The key values here were treated as indexes (integer indexes) and were painted in reverse order.
In Firefox and IE, we will get
“animation apple barbara beery video cheese sticks games bbq pork sticks asian chicken tenders bake banana”
and in chrome
“banana bake asian chicken tenders bbq pork sticks games cheese sticks video barbara beery apple animation”
Convert the object into array, reverse it for chrome browser and then the finally load the dom object.
Note: In case the key was a text then the order of rendering is same across the browsers.