Add sorting to JSON output (refs #579)