from typing import List


def list_to_dangling(lines: List[str], sort: bool = False) -> str:
    """Create a "dangling" multi-line formatted list."""
    stripped = [ln.strip() for ln in lines]  # strip each
    stripped = [ln for ln in stripped if ln]  # kick each out if its empty
    return "\n" + "\n".join(sorted(stripped) if sort else stripped)