You are given a list of tasks, each identified by a unique string. Some tasks depend on the completion of others. The dependency is represented as a pair [A, B] which means task A depends on task B (i.e., B must be completed before A can start).
Your task is to write a function that, given the list of dependencies and the full set of tasks, returns an ordering of tasks such that every task appears after all of the tasks it depends on.
Requirements:
Input Example:
Output Example:
A valid ordering (e.g., ["task2", "task4", "task1", "task3"]) that respects the dependency rules.
Implement your solution in the programming language of your choice. Your code should be well-documented and handle edge cases appropriately.