def METHOD_NAME(self):
    """Performs an inneficient but easy to follow sorting of parts."""
    sorted_parts = []
    # We want to process parts in a consistent order between runs. The
    # simplest way to do this is to sort them by name.
    self.all_parts = sorted(
        self.all_parts, key=lambda part: part.name, reverse=True
    )
    while self.all_parts:
        top_part = None
        for part in self.all_parts:
            mentioned = False
            for other in self.all_parts:
                if part in other.deps:
                    mentioned = True
                    break
            if not mentioned:
                top_part = part
                break
        if not top_part:
            raise errors.SnapcraftLogicError(
                "circular dependency chain found in parts definition"
            )
        sorted_parts = [top_part] + sorted_parts
        self.all_parts.remove(top_part)
    return sorted_parts