More consistent sorting on binary-tree algo

The images are currently sorted by height only.

This is not a problem for most folks, but once you need to start building retina/regular sprites and share the generated stylesheet between them, the sprites need to be as consistent as they can get.