import ast


def _get_class_methods(cls_node, base=None):
    """
    Return a sorted list of the methods in a given class node. The methods in
    the base list (if any) are also included. Private methods are excluded and
    the list is sorted lexically.
    """

    def keep(method):
        n = method.name
        if n.startswith("__"):
            return True
        return not (n.startswith("_") or n.endswith("_"))

    methods = list(base or [])
    for node in ast.iter_child_nodes(cls_node):
        if isinstance(node, ast.FunctionDef) and keep(node):
            methods.append(node.name)

    return sorted(methods)