def _sort_attribute_names(self, names: list[str]) -> list[str]:
        """
        Sort attribute names alphabetically, but move the double underscore and
        underscore names to the end.
        """

        def sort_key(name: str) -> tuple[int, str]:
            if name.startswith("__"):
                return (2, name)  # Double underscore comes latest.
            if name.startswith("_"):
                return (1, name)  # Single underscore before that.
            return (0, name)  # Other names first.

        return sorted(names, key=sort_key)

        Sort attribute names alphabetically, but move the double underscore and
        underscore names to the end.
        
src/ptpython/completer.py