Implement a topological sort algorithm to resolve dependencies between a set of tasks or packages.
Write topological_sort(tasks, dependencies), where tasks is a list of unique strings and each dependency [a, b] means a must be completed before b. Return any valid ordering containing every task exactly once, or return [] if the dependencies contain a cycle. Use the function signature and input shapes below.
def topological_sort(tasks, dependencies):