input: Write a python function to schedule tasks based on their deadlines and durations.
  assert schedule_tasks([("Task A", 2, 5), ("Task B", 1, 3), ("Task C", 3, 7)]) == [("Task B", 1, 3), ("Task A", 2, 5)]
  assert schedule_tasks([("Task A", 1, 2), ("Task B", 2, 4), ("Task C", 1, 3)]) == [("Task A", 1, 2), ("Task C", 1, 3)]
  assert schedule_tasks([("Task A", 3, 5), ("Task B", 2, 6), ("Task C", 1, 4)]) == [("Task C", 1, 4), ("Task B", 2, 6)]
output: def schedule_tasks(tasks):
      # Sort tasks by their deadlines (second element of the tuple)
      tasks.sort(key=lambda x: x[2])
      
      # Initialize the current time and the result list
      current_time = 0
      result = []
      
      for task in tasks:
          name, duration, deadline = task
          if current_time + duration <= deadline:
              result.append(task)
              current_time += duration
              
      return result