Sort top level resources and methods within resources

Required for deterministic sorting order since dicts are unsorted.