Does this work? I mean, the Python code is perfect, but I discovered the other day that JavaScript objects does not guarantee the order of keys[[1](http://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order)] and my sorting in Python was not taking effect :-(