Iterate over sorted members of shape in the same order in which
        the members are declared except yielding the required members before
        any optional members.

def sorted_members(self):
        """
        Iterate over sorted members of shape in the same order in which
        the members are declared except yielding the required members before
        any optional members.
        """
        members = collections.OrderedDict()
        required_names = self.metadata.get("required", ())
        for name, shape in self.members.items():
            members[name] = AbShapeMember(name=name, shape=shape, is_required=name in required_names)

        if self.is_output_shape:
            # ResponseMetadata is the first member for all output shapes.
            yield AbShapeMember(
                name="ResponseMetadata",
                shape=self._shape_resolver.get_shape_by_name("ResponseMetadata"),
                is_required=True,
            )

        yield from sorted(members.values(), key=lambda m: not m.is_required)