<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
 """Discovers all files with certain extension in given paths."""

    file_list = []
    for root, dirs, files in walk(path.join(base_path, sub_path)):
        if trim_base_path:
            root = path.relpath(root, base_path)
        file_list.extend([path.join(root, file_name)
                          for file_name in files
                          if file_name.endswith(ext)])
    return sorted(file_list)