parameters: (tasks)
return_statement: return sorted_tasks
docstring: sort tasks by asset/shot's pipeline
docstring_summary: sort tasks by asset/shot's pipeline
docstring_tokens: sort tasks by asset / shot s pipeline
function: def sort_tasks(tasks):
          '''sort tasks by asset/shot's pipeline'''
          if not tasks:
              return tasks
          # reorder the tasks per shot
          sorted_tasks = []
  
          all_shot_tasks = {}
          key_order = []
          for task in tasks:
              id = task.get_value("search_id")
              search_type = task.get_value("search_type")
  
              key = '%s|%s' %(search_type, id)
              shot_tasks = all_shot_tasks.get(key)
              if not shot_tasks:
                  shot_tasks = []
                  all_shot_tasks[key] = shot_tasks
  
              shot_tasks.append(task)
  
              if key not in key_order:
                  key_order.append(key)
  
  
          for key in key_order:
              shot_tasks = all_shot_tasks.get(key)
              shot_tasks = Task.sort_shot_tasks(shot_tasks)
  
              sorted_tasks.extend(shot_tasks)
  
  
          return sorted_tasks
function_tokens: def sort_tasks ( tasks ) : if not tasks : return tasks # reorder the tasks per shot sorted_tasks = [ ] all_shot_tasks = { } key_order = [ ] for task in tasks : id = task . get_value ( "search_id" ) search_type = task . get_value ( "search_type" ) key = '%s|%s' % ( search_type , id ) shot_tasks = all_shot_tasks . get ( key ) if not shot_tasks : shot_tasks = [ ] all_shot_tasks [ key ] = shot_tasks shot_tasks . append ( task ) if key not in key_order : key_order . append ( key ) for key in key_order : shot_tasks = all_shot_tasks . get ( key ) shot_tasks = Task . sort_shot_tasks ( shot_tasks ) sorted_tasks . extend ( shot_tasks ) return sorted_tasks