Add sorting for JSON string generation to generate stable structures.

Currently the generated JSON strings are not stable, they may change in sorting with every run. This is not so good if you want to checkin the generated documentation into a version control system as it changes every time. This patch enables sorting on the JSON output so that it generates a string that is stable over time and thus does not create new commits in the documentation tree if nothing changed in the source tree.