ByteDance Interview Question

Implement a function to sort tasks that are interdependent.