def METHOD_NAME(preview_versions):
    class CustomFunctions(functions.Functions):  # pylint: disable=too-few-public-methods
        @functions.signature({'types': ['array']})
        def _func_sort_versions(self, versions):  # pylint: disable=no-self-use
            """Custom JMESPath `sort_versions` function that sorts an array of strings as software versions."""
            try:
                return sorted(versions, key=version_to_tuple)
            # if it wasn't sortable, return the input so the pipeline continues
            except (TypeError, ValueError):
                return versions
        @functions.signature({'types': ['array']})
        def _func_set_preview_array(self, versions):
            """Custom JMESPath `set_preview_array` function that suffixes preview version"""
            try:
                for i, _ in enumerate(versions):
                    versions[i] = self._func_set_preview(versions[i])
                return versions
            except (TypeError, ValueError):
                return versions
        @functions.signature({'types': ['string']})
        def _func_set_preview(self, version):  # pylint: disable=no-self-use
            """Custom JMESPath `set_preview` function that suffixes preview version"""
            try:
                if preview_versions.get(version, False):
                    return version + '(preview)'
                return version
            except (TypeError, ValueError):
                return version
    return CustomFunctions()