(tasks)
return sorted_tasks
sort tasks by asset/shot's pipeline
sort tasks by asset/shot's pipeline
sort tasks by asset / shot s pipeline
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
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