Sort nodes before marshalling to json.