from typing import Union
from pathlib import Path
from typing import List


def get_list_of_directories(
    directory_path: Union[str, Path], descending=False
) -> List[Path]:
    """Gets a list of directories in a directory.

    Parameters
    ----------
    directory_path : Union[str, Path]
        The path to the directory.

    Returns
    -------
    List[Path]
        The list of directories.
    """
    if isinstance(directory_path, str):
        directory_path = Path(directory_path)

    return sorted(
        [directory for directory in directory_path.iterdir() if directory.is_dir()],
        reverse=descending,
    )