def filter_list(lst, pattern):
if is_fnmatch_regex(pattern) and not is_regex(pattern):<EOL><INDENT>log.info('<STR_LIT>'.format(pattern))<EOL>filst = fnmatch.filter(lst, pattern)<EOL><DEDENT>else:<EOL><INDENT>log.info('<STR_LIT>'.format(pattern))<EOL>filst = match_list(lst, pattern)<EOL><DEDENT>if filst:<EOL><INDENT>filst.sort()<EOL><DEDENT>return filst<EOL>
Filters the lst using pattern.
If pattern starts with '(' it will be considered a re regular expression,
otherwise it will use fnmatch filter.

:param lst: list of strings

:param pattern: string

:return: list of strings
Filtered list of strings