Added basic sorting to the JSON output.