Ok, so on a web page, I\'ve got a JavaScript object which I\'m using as an associative array. This exists statically in a script block when the page loads:
v
Think of an associative array as a paper sack into which all the key-value pairs are placed. As you reach your hand into the sack to look at the pairs (such as with the for...in loop), the order that you encounter them is for all practical purposes random.
If you want to see them in a specific order, you'll need to extract the keys into an array and sort it. Then walk across the array, using the keys you encounter to index into the associative array.