code: def find_sorted_task_dependencies(task, task_name, task_id):
      log.info("find_sorted_task_dependencies {} {}".format(task_name, task_id))
      cot_input_dependencies = [
          _craft_dependency_tuple(task_name, task_type, task_id)
          for task_type, task_id in task['extra'].get('chainOfTrust', {}).get('inputs', {}).items()
      ]
      upstream_artifacts_dependencies = [
          _craft_dependency_tuple(task_name, artifact_dict['taskType'], artifact_dict['taskId'])
          for artifact_dict in task.get('payload', {}).get('upstreamArtifacts', [])
      ]
      dependencies = [*cot_input_dependencies, *upstream_artifacts_dependencies]
      dependencies = _sort_dependencies_by_name_then_task_id(dependencies)
      parent_task_id = get_parent_task_id(task) or get_decision_task_id(task)
      parent_task_type = 'parent'
      parent_tuple = _craft_dependency_tuple(task_name, parent_task_type, parent_task_id)
      dependencies.insert(0, parent_tuple)
      log.info('found dependencies: {}'.format(dependencies))
      return dependencies