Re-orders a miz file into a folder (flattened)

        Args:
            miz_file_path: source miz file
            target_dir: folder to flatten the content into
            skip_options_file: do not re-order option file

def reorder(
            miz_file_path: typing.Union[str, Path],
            target_dir: typing.Union[str, Path],
            skip_options_file: bool,
    ):
        """
        Re-orders a miz file into a folder (flattened)

        Args:
            miz_file_path: source miz file
            target_dir: folder to flatten the content into
            skip_options_file: do not re-order option file

        """

        miz_file_path = elib.path.ensure_file(miz_file_path)
        target_dir_path = elib.path.ensure_dir(target_dir, must_exist=False)

        LOGGER.debug('re-ordering miz file: %s', miz_file_path)
        LOGGER.debug('destination folder: %s', target_dir)
        LOGGER.debug('%s option file', "skipping" if skip_options_file else "including")

        if not target_dir_path.exists():
            LOGGER.debug('creating directory %s', target_dir_path)
            target_dir_path.mkdir(exist_ok=True)

        with Miz(miz_file_path, overwrite=True) as miz_:

            def mirror_dir(src: Path, dst: Path):
                """
                Propagates difference between the original lua tables and the re-ordered one

                Args:
                    src: source folder
                    dst: destination folder
                """
                LOGGER.debug('mirroring: %s -> %s', src, dst)

                LOGGER.debug('comparing directories')
                diff_ = dircmp(str(src), str(dst), ignore)

                diff_list = diff_.left_only + diff_.diff_files
                LOGGER.debug('differences: %s', diff_list)

                for __diff in diff_list:
                    source = Path(diff_.left, __diff)
                    target = Path(diff_.right, __diff)
                    LOGGER.debug('looking at: %s', __diff)
                    if source.is_dir():
                        LOGGER.debug('isdir: %s', __diff)
                        if not target.exists():
                            LOGGER.debug('creating: %s', __diff)
                            target.mkdir()
                        mirror_dir(source, target)
                    else:
                        LOGGER.debug('copying: %s', __diff)
                        shutil.copy2(str(source), diff_.right)
                for sub in diff_.subdirs.values():

                    mirror_dir(Path(sub.left), Path(sub.right))

            # pylint: disable=protected-access
            miz_._encode()

            if skip_options_file:
                ignore = ['options']
            else:
                ignore = []

            mirror_dir(Path(miz_.temp_dir), target_dir_path)